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