NAME
Zenoss::Response - Handles responses from Zenoss::Router
SYNOPSIS
use Zenoss;
use Data::Dumper;
# Create a Zenoss object
my $api = Zenoss->connect(
{
username => 'admin',
password => 'zenoss',
url => 'http://zenossinstance:8080',
}
);
# Issue a request to get all devices from Zenoss
my $response = $api->device_getDevices();
# $response is now an instance of Zenoss::Response
# now we can do things like
print $response->json();
print $response->http_code();
# get the response in reference form
my $reference = $response->decoded();
print Dumper $reference;
DESCRIPTION
This module is NOT instantiated directly. When the Zenoss API issues a response to a request initiated by Zenoss::Router, a Zenoss::Response instance is created. To call methods from this module create an instance of Zenoss and issue a request to the Zenoss API.
Please review the SYNOPSIS for examples.
ATTRIBUTES
Attributes can be retrieved by calling $obj->attribute.
sent_tid
This attribute is set upon the creation of Zenoss::Response by Zenoss::Router. Each request issued to the Zenoss API is coded with a transaction ID (tid). This can be compared with the received_tid to ensure that the proper response was received for what was requested.
received_tid
This attribute is set by extracting the transaction ID (tid) from the response Zenoss sends. This can be compared with the sent_tid to ensure that the proper response was received for what was requested.
METHODS
$obj->json()
Returns the response, from the Zenoss API request, in JSON format.
$obj->decoded()
Returns the result response, from the Zenoss API request, in a PERL reference.
$obj->raw_response()
Returns a textual representation of the response.
$obj->http_code()
Returns a 3 digit number that encodes the overall outcome of a HTTP response.
For example 200, for OK.
$obj->http_code_description()
Returns a short human readable single line string that explains the response code.
For example, OK.
$obj->http_status()
Returns the string "<http_code> <http_code_description>". If the http_code_description attribute is not set then the official name of <code> (see HTTP::Status) is substituted.
$obj->is_success()
Returns true if the http response was successful. Note this does not mean the API request was successful or not.
See HTTP::Status for the meaning of these.
$obj->is_error()
Returns true if the http response had an error. Note this does not mean the API request was successful or not.
See HTTP::Status for the meaning of these.
$obj->error_as_HTML()
Returns a string containing a complete HTML document indicating what error occurred. This method should only be called when $obj->is_error is TRUE.
$obj->header()
This is used to get header values and it is inherited from HTTP::Headers via HTTP::Message.
$obj->request_time()
Calculates the "current age" of the response as specified by RFC 2616 section 13.2.3. The age of a response is the time since it was sent by the origin server. The returned value is a number representing the age in seconds.
$obj->received_tid()
Returns the transaction id (tid) that was returned by Zenoss.
$obj->sent_tid()
Returns the transaction id (tid) that was sent to Zenoss
SEE ALSO
AUTHOR
Patrick Baker <patricksbaker@gmail.com>
COPYRIGHT AND LICENSE
Copyright (C) 2010 by Patrick Baker <patricksbaker@gmail.com>
This module is free software: you can redistribute it and/or modify it under the terms of the Artistic License 2.0.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You can obtain the Artistic License 2.0 by either viewing the LICENSE file provided with this distribution or by navigating to http://opensource.org/licenses/artistic-license-2.0.php.