-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtenantinfo.js
66 lines (58 loc) · 1.48 KB
/
tenantinfo.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
const runNeoCmd = require("./neocmd.js")
var rp = require("request-promise-native")
var setupEnv = function(dc, landscape) {
let cpms = { appName: "mobile", account: "hanamobileprod" }
if (
landscape.toLowerCase() === "preview" ||
landscape.toLowerCase() === "prev"
) {
cpms.appName = "mobilepreview"
cpms.account = "hanamobilepreview"
}
cpms.host = dc + ".hana.ondemand.com"
return cpms
}
var getTenant = async function(dc, landscape, user, pass, tenantId) {
let cpms = setupEnv(dc, landscape)
let url =
"https://" +
cpms.appName +
"." +
cpms.host +
"/tenantadmin/rest/tenants/" +
tenantId +
"?&includePassword=yes"
var options = {
method: "GET",
uri: url,
json: true,
headers: { Accept: "application/json" }
}
try {
const result = await rp(options).auth(user, pass)
console.log(result)
return result
} catch (err) {
console.error(err)
}
}
var getTenantList = async function(dc, landscape, user, pass) {
let cpms = setupEnv(dc, landscape)
let url =
"https://" + cpms.appName + "." + cpms.host + "/tenantadmin/rest/tenants"
var options = {
method: "GET",
uri: url,
json: true,
headers: { Accept: "application/json" }
}
try {
const result = await rp(options).auth(user, pass)
console.log(result.tenants.length)
//let tenants = JSON.parse(result)
return result.tenants
} catch (err) {
console.error(err)
}
}
module.exports = { getTenant, getTenantList }