[rt-users] Can a scrip do a search like RT::Client::REST does?
Landon
landonstewart at gmail.com
Thu Jun 13 13:38:06 EDT 2013
My scrip looks for currently open Incidents that are related to each of the
IP addresses in CF.{IP} on an Incident Report. If it finds one it links
the Incident Report to that Incident thus making it unnecessary for someone
to do it manually later. This might be changed to CustomerID or something
later.
Anyway - The snippet from my scrip that I'd like to modify with something
more native instead of using RT::Client::REST is the following. Is there a
way to search for tickets without using RT::Client::REST? I've been
reading through page after page but I'm not able to figure this one out.
Is this the only way I'll be able to do it? It works but it logs itself
in to RT via the web interface each time a new Incident Report comes in.
use RT::Client::REST;
use Error qw(:try);
my $rturl = "http://".RT->Config->Get('WebDomain');
my $rt = RT::Client::REST->new( server => $rturl, timeout => 30 );
my $user = 'XXXXXX';
my $pass = 'XXxx11';
try {
$rt->login(username => $user, password => $pass);
} catch Exception::Class::Base with {
die "problem logging in: ", shift->message;
};
my $ips = $self->TicketObj->CustomFieldValues( 'IP' );
while ( my $ipobj = $ips->Next ) {
my $ip = $ipobj->Content;
$RT::Logger->critical("Searching for open incidents related to
".$ip."\n");
my $query = qq/Queue = 'Incidents' AND Status = 'open' AND CF.{IP} =
'$ip'/;
my @ids = $rt->search(
type => 'ticket',
query => $query,
);
foreach my $id (@ids) {
$RT::Logger->critical("Linking to existing Incident #".$id." for
".$ip."\n");
$self->TicketObj->AddLink( Type=>'MemberOf', Target=> $id );
}
}
--
Landon Stewart <LandonStewart at Gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20130613/5758ccf0/attachment.htm>
More information about the rt-users
mailing list