Ahora ya busca bien en todas las organizaciones
This commit is contained in:
parent
cb8fd76e46
commit
034f6d1f82
29
main.js
29
main.js
|
@ -126,10 +126,16 @@ async function main(){
|
||||||
|
|
||||||
if (AllOrganizations.message==='invalid username or password') {
|
if (AllOrganizations.message==='invalid username or password') {
|
||||||
console.error(`\n${error}Invalid username or password\n`.red);
|
console.error(`\n${error}Invalid username or password\n`.red);
|
||||||
process.exit(0);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.clear();
|
console.clear();
|
||||||
|
console.log(
|
||||||
|
`----------`.white,
|
||||||
|
`Grafana-Find (${packageJson.description})`.yellow.bold,
|
||||||
|
`v${packageJson.version}`.cyan.bold,
|
||||||
|
`---------`.white
|
||||||
|
);
|
||||||
console.log(colors.green.bold(`-------------------- Starting process --------------------\n`));
|
console.log(colors.green.bold(`-------------------- Starting process --------------------\n`));
|
||||||
|
|
||||||
for (let x in AllOrganizations) {
|
for (let x in AllOrganizations) {
|
||||||
|
@ -146,6 +152,9 @@ async function main(){
|
||||||
if (response.status === 302) {
|
if (response.status === 302) {
|
||||||
response = await fetch(`${urlDashboards}${AllOrganizations[x].id}`, {
|
response = await fetch(`${urlDashboards}${AllOrganizations[x].id}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json'
|
||||||
|
},
|
||||||
redirect: 'manual'
|
redirect: 'manual'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -153,15 +162,25 @@ async function main(){
|
||||||
let allUID = await response.json();
|
let allUID = await response.json();
|
||||||
|
|
||||||
for (let i in allUID) {
|
for (let i in allUID) {
|
||||||
|
let url = `${urlUID}${allUID[i].uid}`;
|
||||||
let url = urlUID + allUID[i].uid;
|
|
||||||
response = await fetch(url, {
|
response = await fetch(url, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: credentials,
|
Authorization: credentials,
|
||||||
}
|
},
|
||||||
|
redirect: 'manual'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (response.status === 404) {
|
||||||
|
response = await fetch(url, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json'
|
||||||
|
},
|
||||||
|
redirect: 'manual'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let data = await response.json();
|
let data = await response.json();
|
||||||
|
|
||||||
let isFound = false;
|
let isFound = false;
|
||||||
|
@ -222,6 +241,6 @@ async function main(){
|
||||||
|
|
||||||
console.log(colors.green.bold(`-------- Have been found ${numberOfObjects} results in ${numberOfDashboards} dashboards -------\n`));
|
console.log(colors.green.bold(`-------- Have been found ${numberOfObjects} results in ${numberOfDashboards} dashboards -------\n`));
|
||||||
|
|
||||||
process.exit(0);
|
process.exit();
|
||||||
}
|
}
|
||||||
main();
|
main();
|
Loading…
Reference in New Issue