NAME
Splunk::HEC::Response - An object wrapper for HEC responses
SYNOPSIS
use Splunk::HEC;
my $hec = Splunk::HEC->new;
my $res = $hec->send(event => 'testEvent');
if ($res->is_success) { say $res->content }
elsif ($res->is_error) { say $res->reason }
DESCRIPTION
Splunk::HEC::Response is an object wrapper for HEC responses
ATTRIBUTES
Splunk::HEC::Response implements the following attributes.
success
my $sucess = $res->success;
$success = $res->success(0);
Indicates if the HEC request was successful.
status
my $status = $res->status;
$status = $res->status(200);
HTTP Status Code from HEC request.
reason
my $reason = $res->reason;
$reason = $res->reason('An error occurred.');
String error message if the response was an error.
content
my $content = $res->content;
$content = $res->content({text => 'Success', code => 0});
The contents of a successful HEC request (decoded from JSON)
is_error
my $is_error = $res->is_error;
Returns true if the response was an error.
is_success
my $is_success = $res->is_success;
Returns true if the request was a success.
METHODS
Splunk::HEC::Response implements the following methods.
new
my $res = Splunk::HEC::Response->new;
my $res = Splunk::HEC::Response->new(success => 0, reason => 'Generic Error');
my $res = Splunk::HEC::Response->new({success => 0, reason => 'Generic Error'});
This is the constructor used to create the Splunk::HEC::Response object. You can pass it either a hash or a hash reference with attribute values.
TO_JSON
my $hash = $res->TO_JSON;
Returns a JSON encoding friendly hashref for use with JSON::XS
SEE ALSO
Splunk::HEC::Request, Splunk::HEC::Response, Splunk::HEC, HTTP::Tiny, JSON::XS