function request(url) {
    api_request = new HttpRequest();
    api_request.addHeader('Authorization: Basic ' + btoa(params.user + ':' + params.password));
    Zabbix.log(4, '[ DELL ] Sending request: ' + url);

    try {
        response = api_request.get(url);
    } catch (error) {
        Zabbix.log(4, '[ DELL ] Get request returned error ' + error);
        throw 'Get request returned error ' + error + '. Check debug log for more information.';
    }

    Zabbix.log(4, '[ DELL ] Received response with status code ' +
        api_request.getStatus() + '\\n' + response);

    if (api_request.getStatus() !== 200) {
        var message = 'Request failed with status code ' + api_request.getStatus();
        if (response !== null) {
            if (typeof response.message === 'string') {
                message += ': ' + response.message;
            }
        }

        throw message + ' Check debug log for more information.';
    }

    if (response !== null) {
        try {
            response = JSON.parse(response);
        }
        catch (error) {
            Zabbix.log(4, '[ DELL ] Failed to parse response.');
            response = null;
        }
    }

    return {
        status: api_request.getStatus(),
        body: response
    };
}

function getField(object, field, def) {
    var names = field.split('.');
    var name = names.shift();

    while (typeof name !== 'undefined') {
        if (typeof object === undefined || typeof object[name] === 'undefined') {
            return def;
        }

        object = object[name];
        name = names.shift();
    }

    return object;
}

try {
    storages = JSON.parse(value);
}
catch (error) {
    Zabbix.log(4, '[ DELL ] Failed to parse response.');
    storages = null;
}

var params = {
    url: '{$API.URL}',
    user: '{$API.USER}',
    password: '{$API.PASSWORD}'
};
var result = [];

var index = params.url.indexOf('://');
index = params.url.indexOf('/', (index !== -1) ? (index + 3) : 0);
if (index !== -1) {
    params.url = params.url.substring(0, index);
}

if (storages.Members instanceof Array) {
    storages.Members.forEach(function (storage) {
        if (typeof storage["@odata.id"] === 'string') {
            response = request(params.url + storage["@odata.id"]);
            controller = response.body;
            if (getField(controller, 'Id', '').search('RAID') > -1) {
                result.push({
                    '{#CNTLR_NAME}': getField(response.body, 'Name', ''),
                    '{#SLOT}': getField(response.body, 'Oem.Dell.DellController.PCISlot', ''),
                    '{#ODATA}': controller["@odata.id"]
                });
            }
        }
    });
}

return JSON.stringify(result);