Skip to content

Commit c3017ee

Browse files
committed
added messaging
1 parent 021c740 commit c3017ee

File tree

2 files changed

+114
-24
lines changed

2 files changed

+114
-24
lines changed

experimental.js

Lines changed: 91 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ var executionStatus;
2828
var startDate;
2929
var endDate;
3030
var startOrResume;
31+
var queueOrTopic;
32+
var messagingName;
3133
var nextUrl,formUrl;
3234
var finalCall;
3335
var loginStageCounter = 0;
@@ -118,6 +120,33 @@ function getMonitorInfo(inExecutionStatus,inStartDate,inEndDate,inProjectId,inWo
118120
loginPhase1();
119121
}
120122

123+
function messagingDelete(inQueueOrTopic, inProjectId,inMessagingName)
124+
{
125+
projectId = inProjectId;
126+
messagingName = inMessagingName;
127+
queueOrTopic = inQueueOrTopic;
128+
finalCall = doMessagingDelete;
129+
loginPhase1();
130+
}
131+
132+
function messagingCreate(inQueueOrTopic, inProjectId,inMessagingName)
133+
{
134+
projectId = inProjectId;
135+
messagingName = inMessagingName;
136+
queueOrTopic = inQueueOrTopic;
137+
finalCall = doMessagingCreate;
138+
loginPhase1();
139+
}
140+
141+
function messagingStats(inProjectId,inMessagingName)
142+
{
143+
projectId = inProjectId;
144+
messagingName = inMessagingName;
145+
finalCall = getMessagingStats;
146+
loginPhase1();
147+
}
148+
149+
121150
function workflowResubmit(instartOrResume, inStartDate,inEndDate, inProjectId,inWorkflowId)
122151
{
123152
projectId = inProjectId;
@@ -192,7 +221,7 @@ function checkResubmissions()
192221
var body=processMonitorBody();
193222
body.execution_status=["running"];
194223
var headers = setHeaders();
195-
rest.custom(endPoint,undefined,undefined,60,body,undefined,"POST",processRunningResponse,undefined,headers,true,false);
224+
rest.custom(endPoint,undefined,undefined,timeout,body,undefined,"POST",processRunningResponse,undefined,headers,true,false);
196225
}
197226

198227
function processResubmissions(reprocessCount)
@@ -206,7 +235,7 @@ function processResubmissions(reprocessCount)
206235
body.limit=reprocessCount;
207236
body.execution_status=["failed"];
208237
var headers = setHeaders();
209-
rest.custom(endPoint,undefined,undefined,60,body,undefined,"POST",processListResponse,undefined,headers,true,false);
238+
rest.custom(endPoint,undefined,undefined,timeout,body,undefined,"POST",processListResponse,undefined,headers,true,false);
210239
}
211240

212241
function processSingleResubmission(a,b, vbid)
@@ -218,7 +247,7 @@ function processSingleResubmission(a,b, vbid)
218247
//body.limit=reprocessCount;
219248
//body.execution_status=["failed"];
220249
var headers = setHeaders();
221-
rest.custom(endPoint,undefined,undefined,60,undefined,undefined,"GET",processSingleResubmissionResponse,undefined,headers,true,false);
250+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processSingleResubmissionResponse,undefined,headers,true,false);
222251
}
223252

224253
function finishProcessSingleResubmission(vbid,wfuid,payloaduid,projectuid,flowname,stoptime)
@@ -236,7 +265,7 @@ function finishProcessSingleResubmission(vbid,wfuid,payloaduid,projectuid,flowna
236265
{name:"project_uid",value:projectuid},
237266
];
238267
var body = {"bill_uid":vbid,"__is_checkpoint_run__":true,"payload_uid":payloaduid,"checkpointLogs":[]};
239-
rest.custom(endPoint,undefined,undefined,60,body,undefined,"POST",processFinalSingleResubmissionResponse,undefined,headers,true,false);
268+
rest.custom(endPoint,undefined,undefined,timeout,body,undefined,"POST",processFinalSingleResubmissionResponse,undefined,headers,true,false);
240269
}
241270

242271
function processFinalSingleResubmissionResponse(url,err,body,res){
@@ -370,14 +399,51 @@ function processRunningResponse(url,err,body,res){
370399
}
371400
}
372401

402+
function doMessagingCreate()
403+
{
404+
debug("Messaging Item Creation")
405+
var endPoint = "https://" +domainName + "/integration/rest/messaging/admin/destinations?projectName=" + projectId + "&type=" + queueOrTopic;
406+
debug("Next URL [" + endPoint + "]");
407+
var body;
408+
if(queueOrTopic=="queue")body={"queueName":messagingName};
409+
else if (queueOrTopic=="topic")body={"topicName":messagingName}
410+
else dbg.message("Please provide either 'queue' or 'topic'",1);
411+
var headers = setHeaders();
412+
rest.custom(endPoint,undefined,undefined,timeout,body,undefined,"POST",processResponse,undefined,headers,true,false);
413+
}
414+
415+
function doMessagingDelete()
416+
{
417+
debug("Messaging Item Deletion")
418+
var endPoint = "https://" +domainName + "/integration/rest/messaging/admin/destinations/" + messagingName + "?projectName=" + projectId + "&type=" + queueOrTopic;
419+
debug("Next URL [" + endPoint + "]");
420+
var body;
421+
if(queueOrTopic=="queue")body={"queueName":messagingName};
422+
else if (queueOrTopic=="topic")body={"topicName":messagingName}
423+
else dbg.message("Please provide either 'queue' or 'topic'",1);
424+
var headers = setHeaders();
425+
rest.custom(endPoint,undefined,undefined,60,body,undefined,"DELETE",processResponse,undefined,headers,true,false);
426+
//rest.del(endPoint,undefined,undefined,timeout,undefined,processResponse);
427+
}
428+
429+
function getMessagingStats()
430+
{
431+
debug("Messaging Stats");
432+
var endPoint = "https://" +domainName + "/integration/rest/messaging/runtime/destinations/"+messagingName+"/metrics?projectName=" + projectId ;
433+
debug("Next URL [" + endPoint + "]");
434+
var headers = setHeaders();
435+
var body;
436+
rest.custom(endPoint,undefined,undefined,timeout,body,undefined,"GET",processResponse,undefined,headers,true,false);
437+
}
438+
373439
function getLogs()
374440
{
375441
debugMonitorInfo();
376442
var endPoint = "https://" + domainName + "/enterprise/v1/metrics/workflowexecutions/logs";
377443
debug("Next URL [" + endPoint + "]");
378444
var body=processMonitorBody();
379445
var headers = setHeaders();
380-
rest.custom(endPoint,undefined,undefined,60,body,undefined,"POST",processResponse,undefined,headers,true,false);
446+
rest.custom(endPoint,undefined,undefined,timeout,body,undefined,"POST",processResponse,undefined,headers,true,false);
381447
}
382448

383449

@@ -392,7 +458,7 @@ function searchProjectsByName()
392458
{name:"accept",value:"application/json"},
393459
{name:"x-csrf-token",value:csrf},
394460
];
395-
rest.custom(endPoint,undefined,undefined,60,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
461+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
396462
}
397463

398464
function getProjectDeployments()
@@ -407,7 +473,7 @@ function getProjectDeployments()
407473
{name:"project_uid",value:projectId},
408474
{name:"x-csrf-token",value:csrf},
409475
];
410-
rest.custom(endPoint,undefined,undefined,60,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
476+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
411477
}
412478

413479
function stageInfo()
@@ -421,7 +487,7 @@ function stageInfo()
421487
{name:"accept",value:"application/json"},
422488
{name:"x-csrf-token",value:csrf},
423489
];
424-
rest.custom(endPoint,undefined,undefined,60,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
490+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
425491
}
426492

427493
function getProjectAccountConfigInfo()
@@ -436,7 +502,7 @@ function getProjectAccountConfigInfo()
436502
{name:"project_uid",value:projectId},
437503
{name:"x-csrf-token",value:csrf},
438504
];
439-
rest.custom(endPoint,undefined,undefined,60,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
505+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
440506
}
441507

442508

@@ -452,7 +518,7 @@ function usedConnectorAccountsInfo()
452518
{name:"project_uid",value:projectId},
453519
{name:"x-csrf-token",value:csrf},
454520
];
455-
rest.custom(endPoint,undefined,undefined,60,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
521+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
456522
}
457523

458524
function projectWorkflowsInfo()
@@ -468,7 +534,7 @@ function projectWorkflowsInfo()
468534
{name:"project_uid",value:projectId},
469535
{name:"x-csrf-token",value:csrf},
470536
];
471-
rest.custom(endPoint,undefined,undefined,60,undefined,undefined,"GET",processProjectsResponse,undefined,headers,true,false);
537+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processProjectsResponse,undefined,headers,true,false);
472538
}
473539

474540
function projectFlowServicesInfo()
@@ -484,7 +550,7 @@ function projectFlowServicesInfo()
484550
{name:"project_uid",value:projectId},
485551
{name:"x-csrf-token",value:csrf},
486552
];
487-
rest.custom(endPoint,undefined,undefined,60,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
553+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
488554
}
489555

490556

@@ -498,15 +564,15 @@ function execUserInfo()
498564
{name:"authtoken",value:authtoken},
499565
{name:"accept",value:"application/json"},
500566
];
501-
rest.custom(endPoint,undefined,undefined,60,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
567+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
502568
}
503569

504570
/** Logs in via Software AG Cloud! */
505571
function loginPhase1()
506572
{
507573
debug("LOGIN Phase 1")
508574
var endPoint = url + "/integration/sagcloud/";
509-
rest.custom(endPoint,undefined,undefined,60,undefined,undefined,"GET",loginResponse,undefined,undefined,true,false);
575+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",loginResponse,undefined,undefined,true,false);
510576

511577
}
512578

@@ -516,7 +582,7 @@ function loginPhase2()
516582
var endPoint = nextUrl;
517583
debug("Next URL [" + endPoint + "]");
518584
formUrl = endPoint;
519-
rest.custom(endPoint,undefined,undefined,60,undefined,undefined,"GET",loginResponse,undefined,undefined,true,false);
585+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",loginResponse,undefined,undefined,true,false);
520586
}
521587

522588
function loginPhase3()
@@ -533,7 +599,7 @@ function loginPhase3()
533599
var form = [{name:"username",value:username},
534600
{name:"password",value:password}];
535601

536-
rest.custom(endPoint,undefined,undefined,60,undefined,form,"POST",loginResponse,undefined,undefined,true,false);
602+
rest.custom(endPoint,undefined,undefined,timeout,undefined,form,"POST",loginResponse,undefined,undefined,true,false);
537603
}
538604

539605
function loginRedirectPhase(inId)
@@ -545,7 +611,7 @@ function loginRedirectPhase(inId)
545611
var headers = [
546612
{name:"Accept",value:"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"},
547613
];
548-
rest.custom(endPoint,undefined,undefined,60,undefined,undefined,"GET",loginResponse,undefined,undefined,true,false);
614+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",loginResponse,undefined,undefined,true,false);
549615
}
550616

551617
function loginUserPhase(inId)
@@ -558,7 +624,7 @@ function loginUserPhase(inId)
558624
{name:"authtoken",value:authtoken},
559625
{name:"accept",value:"application/json"},
560626
];
561-
rest.custom(endPoint,undefined,undefined,60,undefined,undefined,"GET",processUserResponse,undefined,headers,true,false);
627+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processUserResponse,undefined,headers,true,false);
562628
}
563629

564630
function checkResponse(res,body)
@@ -636,10 +702,10 @@ function processProjectsResponse(url,err,body,res){
636702

637703

638704
if(prettyprint==true){
639-
dbg.message(JSON.stringify(output,null,4),5);
705+
dbg.message(JSON.stringify(output,null,4),-1);
640706
}
641707
else{
642-
dbg.message((JSON.stringify(output)),5);
708+
dbg.message((JSON.stringify(output)),-1);
643709
}
644710
}
645711
else
@@ -653,10 +719,10 @@ function processResponse(url,err,body,res){
653719
if(res.statusCode==200)
654720
{
655721
if(prettyprint==true){
656-
dbg.message(JSON.stringify(body,null,4),5);
722+
dbg.message(JSON.stringify(body,null,4),-1);
657723
}
658724
else{
659-
dbg.message((JSON.stringify(body)),5);
725+
dbg.message((JSON.stringify(body)),-1);
660726
}
661727
}
662728
else
@@ -759,4 +825,6 @@ function loginResponse(url,err,body,res){
759825

760826
}
761827

762-
module.exports = {init,user,stages,projectWorkflows,projectFlowservices,connectorAccounts,getProjectAccountConfig,searchProject,getMonitorInfo,workflowResubmit,projectDeployments};
828+
module.exports = {init,user,stages,projectWorkflows,projectFlowservices,connectorAccounts,
829+
getProjectAccountConfig,searchProject,getMonitorInfo,workflowResubmit,
830+
projectDeployments,messagingCreate,messagingStats,messagingDelete};

wmiocli.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,29 @@ program.command('flowservice-execute <project-id> <flow-name> [input-json]')
672672
experimental.workflowResubmit(restartOrResume, startDate, endDate, projectId,workflowId);
673673
});
674674

675-
675+
program.command('experimental-messaging-create <queue-or-topic> <name> <project-id>',{hidden: true})
676+
.description('Create a messaging queue or topic')
677+
.action((queueOrTopc,name,projectId) => {
678+
checkOptions();
679+
experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint)
680+
experimental.messagingCreate(queueOrTopc,projectId,name);
681+
});
682+
683+
program.command('experimental-messaging-delete <queue-or-topic> <name> <project-id>',{hidden: true})
684+
.description('Delete a messaging queue or topic')
685+
.action((queueOrTopc,name,projectId) => {
686+
checkOptions();
687+
experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint)
688+
experimental.messagingDelete(queueOrTopc,projectId,name);
689+
});
690+
691+
program.command('experimental-messaging-stats <name> <project-id>',{hidden: true})
692+
.description('Get Messaging Stats')
693+
.action((name,projectId) => {
694+
checkOptions();
695+
experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint)
696+
experimental.messagingStats(projectId,name);
697+
});
676698

677699
program.parse();
678700

0 commit comments

Comments
 (0)