UNPKG

liveapicreator-admin-cli

Version:

The NodeJS command line utility for 'CA Live API Creator' DevOps Administration from CA Technologies

37 lines (30 loc) 814 B
var Client = require('node-rest-client').Client; var login = require('../util/login.js'); module.exports = { getContext: function (cmd, cb) { var client = new Client(); var loginInfo = login.login(cmd); if ( ! loginInfo) { return; } client.get(loginInfo.url + "/accounts", { headers: { Authorization: "CALiveAPICreator " + loginInfo.apiKey + ":1", "Content-Type" : "application/json" } }, function(data) { if (data.errorMessage) { console.log(data.errorMessage.red); return; } if (data.length === 0) { console.log("Account context not found".red); } else if (data.length > 1) { console.log("Error: more than one TeamSpace was found -- are you logging as sa?".red); } module.exports.account = data[0]; if (cb) { cb(); } }); } };