Zenoss::Response - Handles responses from Zenoss::Router
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;
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 can be retrieved by calling $obj->attribute.
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.
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.
Returns the response, from the Zenoss API request, in JSON format.
Returns the result response, from the Zenoss API request, in a PERL reference.
Returns a textual representation of the response.
Returns a 3 digit number that encodes the overall outcome of a HTTP response.
For example 200, for OK.
Returns a short human readable single line string that explains the response
code.
For example, OK.
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.
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.
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.
Returns a string containing a complete HTML document indicating what error
occurred. This method should only be called when $obj->is_error is TRUE.
This is used to get header values and it is inherited from HTTP::Headers via
HTTP::Message.
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.
Returns the transaction id (tid) that was returned by Zenoss.
Returns the transaction id (tid) that was sent to Zenoss
- •
- Zenoss
Patrick Baker <patricksbaker@gmail.com>
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>.