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