Sha256: 821fd76a089ece13bb532ca0852c9ed0100b6c2bb9b29fff01ae92b610482dfb

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

import {pluralize} from '../utils';

export const c = {
    ATTRIBUTES: 'ATTRIBUTES',
    OWNED_RESOURCES: 'OWNED_RESOURCES',
    ALL_ROLES: 'ALL_ROLES',
    RESOURCE: 'RESOURCE',
    PUBLIC_KEYS: 'PUBLIC_KEYS'
};

const encode = window.encodeURIComponent;

export function fetch(rmanager, type, kind, id) {
    switch (type) {
    case c.ATTRIBUTES:
        return rmanager
            .callServer('GET', `/api/${pluralize(kind)}/${encode(id)}`)
            .end();

    case c.OWNED_RESOURCES:
        var roleid = [kind, id].join(':');

        return rmanager
            .callServer('GET', `/api/authz/\${account}/resources?owner=${roleid}`)
            .end()
            .then(function(res) {
                res.body = res.body.filter(function(item) {
                    // assets of 'secret' kind are internal
                    return item.id.split(':')[1] !== 'secret';
                });

                return res;
            });

    case c.ALL_ROLES:
        return rmanager
            .callServer('GET', `/api/authz/\${account}/roles/${encode(kind)}/${encode(id)}?all`)
            .end();

    case c.RESOURCE:
        return rmanager
            .callServer('GET', `/api/authz/\${account}/resources/${kind}/${encode(id)}`)
            .end();

    case c.PUBLIC_KEYS:
        return rmanager
            .callServer('GET', `/api/pubkeys/${encode(id)}`)
            .end();

    default:
    }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conjur-asset-ui-1.6.0 app/src/clients/generic.js