Jump to content


working example using 4.x/5.x API

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 Aaron Bliss

Aaron Bliss
  • Members
  • 1 posts

Posted 04 March 2011 - 02:29 PM

Hi all,I thought I would share this, as I couldn't find any working examples of the 4.x API. As an aside, I asked (practically begged) Barracuda support for the short snip-it of code to help make this go faster, and their response was they don't have any). In short, they refused any relevant help with this. An amazing response since they wrote the actual API.---------------------------------------------------------#!/usr/bin/perluse strict;use warnings;use XML::RPC;use Data::Dumper;# setup the URL to the API scriptmy $xmlrpc = XML::RPC->new('http://barruda_dns_name:8000/cgi-mod/api.cgi?password=your_admin_password');#setup input passed to the scriptmy $varpassnum = @ARGV;print "number of arguments passed was $varpassnumn";#start counting at 0 since @ARGV starts at 1my $count = 0;while ($count < $varpassnum) { #set myvartoprocess equal next argument passed to script my $myvartoprocess = $ARGV[$count]; #increment counter $count ++; print "processing argument $myvartoprocessn"; #our work to do on the cuda #this should add address to list of blocked sender addresses my $result = $xmlrpc->call( 'config.create', { parent_type => 'global', parent_path => ' ', type => 'mta_acl_email_src_block_address', name => $myvartoprocess } ); print Dumper($result); #this should set the action to quarantine $result = $xmlrpc->call( 'config.set', { type => 'mta_acl_email_src_block_address', path => $myvartoprocess, mta_acl_email_src_block_action => 'Quarantine'} ); #this will verify the block was added $result = $xmlrpc->call( 'config.get', { type => 'mta_acl_email_src_block_address', variable => 'mta_acl_email_src_block_action', path => $myvartoprocess} ); #verify that the block was added print Dumper($result);}#finally commit results to filter#end my $result1 = $xmlrpc->call( 'config.reload' ); print Dumper($result1);