/* global conjur, jQuery, async */ (function(conjur, $, async, errback) { 'use strict'; var Generic = this.Generic; var Variable = this.Variable = function(args) { if (!(this instanceof Variable)) { return new Variable(args); } var superArguments = Array.prototype.slice.call(arguments); superArguments.unshift('variable'); Generic.apply(this, superArguments); return undefined; }; Variable.prototype = Object.create(Generic.prototype); Variable.prototype.constructor = Variable; Variable.prototype.fetch = function(callback, customErrback) { var id = this.id; if (typeof(customErrback) === 'undefined') { customErrback = errback; // reset to default } function members(privilege) { return function(cb) { $.ajax({ url: '/api/authz/' + conjur.app.configuration.account + '/roles/allowed_to/' + privilege + '/variable/' + window.encodeURIComponent(id), success: function(result) { cb(null, result); }, error: cb }); }; } async.parallel([ this.attributes.bind(this), members('execute'), members('update'), this.resource.bind(this), this.auditResource.bind(this) ], function(err, results) { if (err) { return customErrback(err.status); } callback({ variable: results[0], fetchers: results[1], updaters: results[2], owner: results[3].owner, annotations: results[3].annotations, audit: results[4] }); return undefined; }); }; }).bind(conjur.models.Record) ( conjur, jQuery, async, conjur.utils.errback );