packages/teraslice-cli/cmds/lib/display.js
async function parseResponse(header, response, active = false, id) {
    const rows = [];
    _.each(response, (value, key) => {
        let row = [];
        if (active) {
            _.each(response[key].active, (activeValue) => {
                row = [];
                // filter by id
                if (id === undefined || activeValue.job_id === id || activeValue.ex_id === id) {
                    _.each(header, (item) => {
                        if (item === 'teraslice_version') {
                            row.push(response[key].teraslice_version);
                        } else if (item === 'node_id') {
                            row.push(response[key].node_id);
                        } else if (item === 'hostname') {
                            row.push(response[key].hostname);
                        } else if (item === 'node_version') {
                            row.push(response[key].node_version);
                        } else {
                            row.push(activeValue[item]);
                        }
                    });
                    rows.push(row);
                }
            });
        } else {
            _.each(header, (item) => {
                if (item === 'active') {
                    row.push(response[key][item].length);
                } else {
                    row.push(response[key][item]);
                }
            });
            rows.push(row);
        }
    });
    return rows;
}
async function parseResponse(header, response, active = false, id) {
    const rows = [];
    _.each(response, (value, key) => {
        let row = [];
        if (active) {
            _.each(response[key].active, (activeValue) => {
                row = [];
                // filter by id
                if (id === undefined || activeValue.job_id === id || activeValue.ex_id === id) {
                    _.each(header, (item) => {
                        if (item === 'teraslice_version') {
                            row.push(response[key].teraslice_version);
                        } else if (item === 'node_id') {
                            row.push(response[key].node_id);
                        } else if (item === 'hostname') {
                            row.push(response[key].hostname);
                        } else if (item === 'node_version') {
                            row.push(response[key].node_version);
                        } else {
                            row.push(activeValue[item]);
                        }
                    });
                    rows.push(row);
                }
            });
        } else {
            _.each(header, (item) => {
                if (item === 'active') {
                    row.push(response[key][item].length);
                } else {
                    row.push(response[key][item]);
                }
            });
            rows.push(row);
        }
    });
    return rows;
}
async function parseResponse ( header , response , active = false , id ) { const rows = [ ] ; _ . each ( response , ( value , key ) => { let row = [ ] ; if ( active ) { _ . each ( response [ key ] . active , ( activeValue ) => { row = [ ] ; // filter by id if ( id === undefined || activeValue . job_id === id || activeValue . ex_id === id ) { _ . each ( header , ( item ) => { if ( item === 'teraslice_version' ) { row . push ( response [ key ] . teraslice_version ) ; } else if ( item === 'node_id' ) { row . push ( response [ key ] . node_id ) ; } else if ( item === 'hostname' ) { row . push ( response [ key ] . hostname ) ; } else if ( item === 'node_version' ) { row . push ( response [ key ] . node_version ) ; } else { row . push ( activeValue [ item ] ) ; } } ) ; rows . push ( row ) ; } } ) ; } else { _ . each ( header , ( item ) => { if ( item === 'active' ) { row . push ( response [ key ] [ item ] . length ) ; } else { row . push ( response [ key ] [ item ] ) ; } } ) ; rows . push ( row ) ; } } ) ; return rows ; }
Parses the teraslice client endpoint responses into an array used to generate
tables in command line output.

@param {Array} header - Header values to include in output
@param {Object} response - Teraslice client response object
@param {Boolean} active - When set to true parse values in active list
@param {String} id - id value used to filter results by job_id or ex_id
@returns {Array} rows - Table content is an array of arrays with
each row an element in the array.
Parses the teraslice client endpoint responses into an array used to generate tables in command line output .