Skip to content

Commit

Permalink
added trigger.exists method
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Abraham committed Sep 3, 2012
1 parent 767346d commit 8fbae3f
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ pm_to_blib
tmp/
*.tar
*.tar.gz
bin/test.pl
2 changes: 2 additions & 0 deletions lib/Pabbix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use strict;
use warnings;
use Pabbix::Auth;
use Pabbix::Trigger::Get;
use Pabbix::Trigger::Exist;

require Exporter;

our @ISA = qw(Exporter);
Expand Down
80 changes: 80 additions & 0 deletions lib/Pabbix/Trigger/Exist.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package Pabbix::Trigger::Exist;

use strict;
use warnings;
use Moo;
use Pabbix::Request;
use Data::Dumper;

sub exist
{
my $self = shift;

my $response = Pabbix::Request->new(
url => $self->url,
json => $self->_createJson,
);
return $response->get;
}

sub _createJson
{
my $self = shift;
my $json = {
jsonrpc => "2.0",
method => "trigger.exists",
params => {
description => $self->description,
expression => $self->expression,
},
auth => $self->authToken,
id => 0
};

if( $self->hostid )
{
$json->{'params'}{'hostid'} = $self->hostid;
}
if( $self->host )
{
$json->{'params'}{'host'} = $self->host;
}
if( $self->nodeids )
{
$json->{'params'}{'nodeids'} = $self->nodeids;
}

return $json;
}

has url => (
is => 'ro',
);

has authToken => (
is => 'ro',
);

has host => (
is => 'ro',
);

has hostid => (
is => 'ro',
);

has description => (
is => 'ro',
required => 1,
);

has expression => (
is => 'ro',
required => 1,
);

has nodeids => (
is => 'ro',
);

1;
2 changes: 1 addition & 1 deletion lib/Pabbix/Trigger/Get.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ has authToken => (
);

has statusValue => (
is => 'ro'
is => 'ro',
);

1;

0 comments on commit 8fbae3f

Please sign in to comment.