We use cookies on our website to ensure we provide you with the best experience on our website. By using our website, you agree to the use of cookies for analytics and personalized content.This website uses cookies. More Information
It seems like your browser didn't download the required fonts. Please revise your security settings and try again.

General APIs

  • Last updated on

The API interfaces presented in this section are general in that they are applicable to the Barracuda Email Security Gateway as well as to other Barracuda Networks appliances. The examples presented here are specific to the Barracuda Email Security Gateway.

Example: Config.get

Use this method to retrieve values of variables in the system configuration. If the variable requested has only a single value (Spam Tag Configuration Subject Tag level, for example), the output will be different than the output for a variable that contains a list (users, domains, etc.). This method gets the value of the variable in the object of $type named $path. The return $value is a reference to an array if it is multi-valued, i.e. a list.

Refer to the example in Single Value Response for getting a variable with a single value and to Multi-value Response for getting a variable that contains a list. Arguments to the method can be specified by just adding the parameter in the XML request.

Parameters Allowed

The following variables are used with the config.get method. These variables should be provided as part of the request XML in the HTTP POST request.

  • variable – A required parameter that tells the API which variable to return.
  • password – A required parameter which the API uses to authenticate access to a page and which is set by your administrator.
  • type – A required parameter that specifies the class/scope of a variable.
  • path – A required parameter that is the qualified name of an object for which the value is required. Note that the value for path is an empty string for getting a variable under global scope.

Get the Value of a Variable under Global Scope - System Alerts Email Address

Getting the current value of a system variable uses the config.get method. This example gets the value of the System Alerts Email Address variable, typically set from the BASIC > Administration page.

Arguments
  • type: 'global'
  • variable: alerts_email_address

The name of the variable, alerts_email_address, is shown in the <input_id>, to the right of Update_.

SysAlertsVarName.png

XML Code for this Example

Note that the name tag indicates that the API applies to a single variable in the configuration. The value tag indicates that the expected value of that variable is a string, and takes the variable name noted above, alerts_email_address, as the input.

<?xml version="1.0" encoding="UTF8"?>
 <methodCall>
  <methodName>config.get</methodName>
    <params>
     <param>
      <value>
        <struct>
         <member>
           <name>variable</name>
           <value><string><![CDATA[alerts_email_addressl]]></string>
           </value>
         </member>
         <member>
           <name>type</name>
           <value><string><![CDATA[global]]></string>
           </value>
         </member>
        </struct>
       </value>
     </param>
    </params>
  </methodCall>  
Perl Code for this Example

Be sure to use single quotes to surround literal values in your calls, and use double quotes to surround variables.

use strict;
use warnings;
use XML::RPC;
 
# IP Address of your Barracuda Web Filter
my $cuda_ip = "10.5.7.211";
# API Password
my $password = "1234";
my $url = "  http://$cuda_ip:8000/cgi-mod/api.cgi?password=$password  ";
 
#Create the XML::RPC object
my $xmlrpc = XML::RPC->new ($url);
my $result;
 
$result = $xmlrpc->call ('config.get',
                        {
          type => 'global',
          variable => 'alerts_email_address',
       });
 
# show the response from the Barracuda Web Filter
print "--- RESPONSE ---";
print $xmlrpc->xml_in();
# END
XML Response Returned by Perl Script

Here is the XML response returned after running the above Perl script, returning myalerts@barracuda.com as the System Alerts Email Address

<methodResponse>
<params>
<param>
<value>
<string><![CDATA[myalerts@barracuda.com]]></string>
</value>
</param>
</params>
</methodResponse>

For more examples, see Config.get and Config.get - Tied Variable Examples.

Last updated on