| QualysGuard-Request documentation | Contained in the QualysGuard-Request distribution. |
QualysGuard::Response - subclass of XML::XPath used to handle QualysGuard API XML responses
Version 0.02
use QualysGuard::Request;
$QualysGuard::Request::Username = "username";
$QualysGuard::Request::Password = "password";
my $qualys_request = QualysGuard::Request->new( 'map_report_list' );
# - provide map_report_list function arguments
$qualys_request->attributes({
'last' => 'yes',
'domain' => 'example.com',
});
my $qualys_response = $qualys_request->submit();
if ( $qualys_response->is_error() ) {
die $qualys_response->get_error();
}
$qualys_response->save_to( 'map_report_list.xml' );
...
A subclass of XML::XPath.
This is a base abstract class that is used to define core methods and attributes shared across all QualysGuard::Response subclasses. Don't use this class directly.
Returns a 1 or 0 based on the results of the requested QualysGuard function.
Returns the native QualysGuard API error code.
Returns the QualysGuard API error code and error message returned by the QualysGuard function.
Saves out the XML response returned from the QualysGuard function.
Patrick Devlin, <pdevlin at cpan.org>
Please report any bugs or feature requests to bug-qualysguard-request at rt.cpan.org, or through
the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=QualysGuard::Request. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc QualysGuard::Request
You can also look for information at:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=QualysGuard::Request
Copyright 2008 Patrick Devlin, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Qualys and the QualysGuard product are registered trademarks of Qualys, Inc.
| QualysGuard-Request documentation | Contained in the QualysGuard-Request distribution. |
package QualysGuard::Response; use warnings; use strict; use base qw( XML::XPath ); use IO::File; use Carp; our $VERSION = '0.02'; # ------------------------------------------------------------------- # new - constructor # ------------------------------------------------------------------- sub new { my ( $class, $xml ) = @_; if ( ! defined $xml ) { croak "Missing or undefined XML response"; } my $self = __PACKAGE__->SUPER::new( $xml ); # -- extract the DOCTYPE my $doctype = (split("\n", $xml))[1]; if ( $doctype !~ m/^<!DOCTYPE\ (.*)\ SYSTEM "(.[^"]*)">/ ) { croak "Missing on unknown DOCTYPE"; } $self->{doctype} = $1; $self->{dtd} = $2; $self->{data} = undef; $self->{xsl_output} = undef; $self->{error_code} = undef; $self->{error_text} = undef; return $self; } # ------------------------------------------------------------------- # is_error # ------------------------------------------------------------------- sub is_error { my $self = shift; return ( defined $self->{error_code} ) ? 1 : 0; } # ------------------------------------------------------------------- # error_code # ------------------------------------------------------------------- sub error_code { my $self = shift; if ( $self->is_error() ) { return $self->{error_code}; } } # ------------------------------------------------------------------- # get_error # ------------------------------------------------------------------- sub get_error { my $self = shift; if ( $self->is_error() ) { return sprintf("Qualys Error [%s] : %s", $self->{error_code}, $self->{error_text} ); } } # ------------------------------------------------------------------- # save_to # ------------------------------------------------------------------- sub save_to { my $self = shift; my $filename = shift; my $FH = IO::File->new(); if ( $FH->open("> $filename") ) { print $FH $self->get_xml(); $FH->close(); } else { carp "Error : $!"; } } 1; __END__