var params = JSON.parse(value);

params['url'] = params.scheme + '://'
	+ params.host + ':'
	+ params.port + '/v1/auth/token/lookup-accessor';

var request = new HttpRequest(),
	output = [];

request.addHeader('X-Vault-Token: ' + params.token);

params.accessors.trim().split(/\x20+/).forEach(function (accessor) {
	if (!accessor) {
		return;
	}

	var response,
		data = {},
		error_msg = '';

	try {
		response = request.post(params.url, JSON.stringify({ accessor: accessor }));
		Zabbix.log(4, '[ Vault API ] Received response with status code ' + request.getStatus() + ': ' + response);

		if (response !== null) {
			try {
				response = JSON.parse(response);
			}
			catch (error) {
				throw 'Failed to parse response received from Vault API. Check debug log for more information.';
			}
		}

		if (request.getStatus() !== 200) {
			throw response.errors && response.errors[0] || JSON.stringify(response);
		}

		if (typeof response !== 'object' || typeof response.data === 'undefined') {
			throw 'Cannot lookup token from Vault API. Check debug log for more information.';
		}

		data = response.data;
	}
	catch (error) {
		error_msg = error;
	}

	output.push({
		'accessor': accessor,
		'token_name': data.display_name || 'null',
		'ttl': data.ttl || 0,
		'has_ttl': !!data.expire_time,
		'error': error_msg.toString()
	});
});

return JSON.stringify(output);