-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
211 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package WWW::Monitis::API::HTTP; | ||
|
||
use warnings; | ||
use strict; | ||
require Carp; | ||
|
||
use base 'WWW::Monitis::API'; | ||
|
||
sub add { | ||
my ( $self, %params ) = @_; | ||
|
||
my @mandatory = qw/userAgentId contentMatchFlag contentMatchString httpMethod timeout url name tag/; | ||
my @optional = qw/loadFull overSSL passAuth postData redirect userAuth /; | ||
|
||
my $params = $self->prepare_params( \%params, \@mandatory, \@optional ); | ||
|
||
return $self->api_post( 'addInternalHttpMonitor' => $params ); | ||
} | ||
|
||
sub edit { | ||
my ( $self, %params ) = @_; | ||
|
||
my @mandatory = qw/testId contentMatchString httpMethod urlParams timeout name tag/; | ||
my @optional = qw/passAuth userAuth postData/; | ||
|
||
my $params = $self->prepare_params( \%params, \@mandatory, \@optional ); | ||
|
||
return $self->api_post( 'editInternalHttpMonitor' => $params ); | ||
} | ||
|
||
sub get { | ||
my ( $self, %params ) = @_; | ||
|
||
my @mandatory = qw/agentId/; | ||
my @optional = qw//; | ||
|
||
my $params = $self->prepare_params(\%params, \@mandatory, \@optional); | ||
|
||
return $self->api_get('agentHttpTests' => $params); | ||
} | ||
|
||
sub get_info { | ||
my ( $self, %params ) = @_; | ||
|
||
my @mandatory = qw/monitorId/; | ||
my @optional = qw//; | ||
|
||
my $params = $self->prepare_params(\%params, \@mandatory, \@optional); | ||
|
||
return $self->api_get('internalHttpInfo' => $params); | ||
} | ||
|
||
sub get_results { | ||
my ( $self, %params ) = @_; | ||
|
||
my @mandatory = qw/monitorId day month year/; | ||
my @optional = qw/timezone/; | ||
|
||
my $params = $self->prepare_params(\%params, \@mandatory, \@optional); | ||
|
||
return $self->api_get('internalHttpResult' => $params); | ||
} | ||
|
||
|
||
__END__ | ||
=head1 NAME | ||
WWW::Monitis::API::HTTP - [One line description of module's purpose here] | ||
=head1 SYNOPSIS | ||
use WWW::Monitis::API::HTTP; | ||
=head1 DESCRIPTION | ||
=head1 ATTRIBUTES | ||
L<WWW::Monitis::API::Layout> implements following attributes: | ||
=head1 METHODS | ||
L<WWW::Monitis::API::Layout> implements following methods: | ||
=head1 BUGS AND LIMITATIONS | ||
Please report any bugs or feature requests to | ||
C<bug-www-monitis-api-subaccounts@rt.cpan.org>, or through the web interface at | ||
L<http://rt.cpan.org>. | ||
=head1 AUTHOR | ||
Yaroslav Korshak C<< <ykorshak@gmail.com> >> | ||
=head1 LICENCE AND COPYRIGHT | ||
Copyright (c) 2011, Yaroslav Korshak C<< <ykorshak@gmail.com> >>. All rights reserved. | ||
This module is free software; you can redistribute it and/or | ||
modify it under the same terms as Perl itself. See L<perlartistic>. | ||
=head1 DISCLAIMER OF WARRANTY | ||
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY | ||
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN | ||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES | ||
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER | ||
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE | ||
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH | ||
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL | ||
NECESSARY SERVICING, REPAIR, OR CORRECTION. | ||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | ||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR | ||
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE | ||
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, | ||
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE | ||
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING | ||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A | ||
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF | ||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF | ||
SUCH DAMAGES. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
use lib 't/lib'; | ||
use Test::Monitis tests => 8, live => 1; | ||
use Data::Dumper; | ||
|
||
my $api = WWW::Monitis::API->new( | ||
api_key => $ENV{MONITIS_API_KEY}, | ||
secret_key => $ENV{MONITIS_SECRET_KEY} | ||
); | ||
|
||
note | ||
'Action addInternalHttpMonitor (http->add) ###########################################'; | ||
|
||
# TODO: Make a good request to API -> We not have Agents in monitoring system. | ||
my $response = $api->http->add( | ||
userAgentId => '', | ||
contentMatchFlag => '', | ||
contentMatchString => '', | ||
httpMethod => '', | ||
timeout => '', | ||
url => '', | ||
name => '', | ||
tag => '' | ||
); | ||
|
||
isa_ok $response, 'HASH', 'JSON response ok'; | ||
is $response->{status}, 'ok', 'status ok'; | ||
like $response->{data}{testId}, qr/^\d+$/, 'API returned test id'; | ||
|
||
my $test_id = $response->{data}{testId}; | ||
warn Dumper $response; | ||
note | ||
'Action editInternalHttpMonitor (http->edit) ###########################################'; | ||
|
||
my $response = $api->http->edit( | ||
testId => '', | ||
contentMatchString => '', | ||
httpMethod => '', | ||
urlParams => '', | ||
timeout => '', | ||
name => '', | ||
tag => '' | ||
); | ||
|
||
isa_ok $response, 'HASH', 'JSON response ok'; | ||
is $response->{status}, 'ok', 'status ok'; | ||
|
||
note | ||
'Action agentInternalHttp (http->get) ###########################################'; | ||
|
||
my $response = $api->http->get( agentId => "$test_id" ); | ||
|
||
isa_ok $response, 'HASH', 'JSON response ok'; | ||
warn Dumper $response; | ||
|
||
note | ||
'Action InternalHttpInfo (http->get_info) ###########################################'; | ||
|
||
my $response = $api->http->get_info( monitorId => "$test_id" ); | ||
|
||
isa_ok $response, 'HASH', 'JSON response ok'; | ||
warn Dumper $response; | ||
|
||
note | ||
'Action httpResult (http->get_results) ###########################################'; | ||
|
||
my $response = $api->http->get_results( | ||
monitorId => "$test_id", | ||
day => '29', | ||
month => '5', | ||
year => '2011' | ||
); | ||
|
||
isa_ok $response, 'HASH', 'JSON response ok'; | ||
warn Dumper $response; | ||
|
||
note | ||
'Action tophttp (http->get_top_results) ###########################################'; | ||
|
||
my $response = $api->http->get_top_results; | ||
|
||
isa_ok $response, 'HASH', 'JSON response ok'; | ||
warn Dumper $response; |