Last active
March 24, 2016 04:56
-
-
Save mindspank/867cb5c1f951060d0435 to your computer and use it in GitHub Desktop.
ObjectDump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var qsocks = require('qsocks'); | |
var Promise = require('bluebird'); | |
var fs = require('fs-extra'); | |
var config = { | |
isSecure: true, | |
host: '<HOSTNAME>', | |
port: 4747, | |
headers: { | |
'X-Qlik-User': 'UserDirectory=Internal;UserId=sa_repository' | |
}, | |
cert: fs.readFileSync('./client.pem'), | |
key: fs.readFileSync('./client_key.pem'), | |
rejectUnauthorized: false | |
}; | |
var main = qsocks.Connect(config); | |
main.then(function(global) { | |
return global.getDocList().then(function(doclist) { | |
return doclist.map(function(d) { | |
return {id: d.qDocId, name: d.qTitle}; | |
}) | |
}) | |
}) | |
.then(function(list) { | |
return Promise.map(list, function(d, i) { | |
var c = config; | |
c.appname = d.id; | |
return qsocks.Connect(c).then(function(global) { | |
return global.openDoc(d.id, '', '', '', true); | |
}) | |
.then(function(app) { | |
return app.getAllInfos().then(function(obj) { | |
return obj; | |
}); | |
}) | |
.then(function(objectlist) { | |
return list[i].objects = objectlist | |
}) | |
}, { concurrency: 10} ) | |
.then(function() { | |
return list | |
}) | |
}) | |
.then(function(list) { | |
return fs.writeJsonSync('./objects.json', {apps: list}); | |
}) | |
.catch(function(err) { | |
console.log(err); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment