Sha256: 19c6b351c619790b88cc945ccd1694ab6efcecf338031672ac38956f2e5b7be1

Contents?: true

Size: 1.94 KB

Versions: 2

Compression:

Stored size: 1.94 KB

Contents

(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, custom_errback) {
        var self = this,
            id = this.id;

        if (typeof(custom_errback) === 'undefined') {
            custom_errback = 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)
        ], function(err, results) {
            if (err) {
                return custom_errback(err.status);
            }

            callback({
                variable: results[0],
                fetchers: results[1],
                updaters: results[2],
                annotations: results[3].annotations
            });

            return undefined;
        });
    };

}).bind(conjur.models.Record)
(
    conjur,
    jQuery,
    async,
    conjur.utils.errback
);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
conjur-asset-ui-1.3.2 public/js/models/variableRecord.js
conjur-asset-ui-1.3.0 public/js/models/variableRecord.js