Infoblox::Grid::NamedACL - Named ACL object.
Named ACL object represents a named list of access control entries.
my $nacl = Infoblox::Grid::NamedACL->new( 'name' => $string, # Required 'comment' => $string, # Optional 'access_list' => [ $ipv4addr | $ipv4_subnet/prefix | $ipv6addr | # Optional $ipv6_subnet/prefix | $TSIGKey | $NamedACL, ... ], 'extattrs' => { $string => $extattr, ... }, # Optional / Default is undefined 'extensible_attributes' => { $string => $string | $num, $string => [ $string | $num, ... ], ... }, # Optional );
You cannot set both extattrs and extensible_attributes attributes at the same time.
This section describes all the methods in the Infoblox::Session module that you can apply to a Named ACL object.
Use this method to retrieve all the matching objects from the Infoblox appliance. See Infoblox::Session->get() for parameters and return values.
Apply the following attributes to get a specific Named ACL object:
name - Optional. The name of Named ACL object. comment - Optional. The comment in string format. extattrs- Optional. A hash reference containing extensible attributes.
my @retrieved_objs = $session->get( object => 'Infoblox::Grid::NamedACL', name => 'nacl', );
Use this method to modify an object in the Infoblox appliance. See Infoblox::Session->modify() for parameters and return values.
If you have applied an access control list to an object, you must restart services after you update the access control list for the changes to take effect. See Infoblox::Session->restart() method.
# Use this method to modify comment of Named ACL object. $nacl->comment('new comment'); # Submit modification my $response = $session->modify( $nacl );
Use this method to remove an object from the Infoblox appliance. See Infoblox::Session->remove() for parameters and return values.
To remove a specific object, first use get()
or search()
to retrieve the specific object, and then submit this object for removal.
# Get the objects with the same name my @retrieved_objs = $session->get( object => "Infoblox::Grid::NamedACL", name => "nacl"); # Find the desired object from the retrieved list. my $desired_nacl = $retrieved_objs[0]; # Submit for removal my $response = $session->remove( $desired_nacl );
Use this method to search for Named ACL objects in the Infoblox appliance. See Infoblox::Session->search() for parameters and return values.
Apply the following attributes to search for Named ACL objects:
name - Optional. The name of Named ACL object (regular expression). comment - Optional. The comment in string format (regular expression). extattrs- Optional. A hash reference containing extensible attributes.
my @retrieved_objs = $session->search( object => 'Infoblox::Grid::NamedACL', name => 'nacl', );
Retrieved Named ACL objects in an access list are considered 'partial' objects. See Infoblox::Session->fill_partial_object() for more information on how it can be converted to a 'full' API object.
This section describes all the methods that you can use to configure and retrieve the attribute values of Named ACL object.
Use this method to set or retrieve an access list of Named ACL object.
The valid value is an array reference that contains IPv4/IPv6 addresses, networks, Infoblox::DNS::TSIGKey objects and/or Infoblox::Grid::NamedACL objects.
To deny queries from certain IP addresses and networks, add "!" as a prefix to the IP addresses and networks.
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
# Get attribute value my $value = $nacl->access_list(); # Modify attribute value $nacl->access_list(['10.0.0.1', $tsigkey, $nacl]);
Use this method to set or retrieve a descriptive comment about Named ACL object.
Desired comment in string format with a maximum of 256 bytes.
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
# Get attribute value my $value = $nacl->comment(); # Modify attribute value $nacl->comment('modified comment');
Use this method to retrieve the exploded access list of the Named ACL object. This is a read-only attribute.
None.
The method returns the attribute value.
The valid value is an array reference that contains IPv4/IPv6 addresses, networks and/or Infoblox::DNS::TSIGKey objects.
# Get attribute value my $value = $nacl->exploded_access_list();
Use this method to set or retrieve the extensible attributes associated with a Named ACL object.
Valid value is a hash reference containing the names of extensible attributes and their associated values ( Infoblox::Grid::Extattr objects ).
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
#Get extattrs my $ref_extattrs = $nacl->extattrs(); #Modify extattrs $nacl->extattrs({ 'Site' => $extattr1, 'Administrator' => $extattr2 });
Use this method to set or retrieve the extensible attributes associated with Named ACL object.
For valid values for extensible attributes, see Infoblox::Grid::ExtensibleAttributeDef/Extensible Attribute Values.
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
# Get attribute value my $value = $nacl->extensible_attributes(); # Modify attribute value $nacl->extensible_attributes({ 'Site' => 'Santa Clara', 'Administrator' => [ 'Peter', 'Tom' ] });
Use this method to set or retrieve the name of the Named ACL object.
The name of the Named ACL object in string format.
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
# Get attribute value my $value = $nacl->name(); # Modify attribute value $nacl->name('new_nacl');
The following sample code demonstrates the different functions that can be applied to an object such as add, get, modify, search and remove. This sample also includes error handling for the operations.
#Preparation prior to getting and modifying an object
use strict; use Infoblox;
#refers to Infoblox Appliance IP address my $host_ip = "192.168.1.2";
#Create a session to the Infoblox appliance
my $session = Infoblox::Session->new( master => $host_ip, username => "admin", password => "infoblox" ); unless ($session) { die("Construct session failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "Session created successfully\n";
#Create an object
my $nacl = Infoblox::Grid::NamedACL->new( name => "NACL", access_list => ['10.0.0.1', '20.0.0.0/24'], comment => "Script Generated", ); unless ($nacl) { die("Construct object failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "The object created successfully\n";
#Adding the object to appliance through session my $response = $session->add( $nacl );
unless ($response) { die("Add object failed: ", $session->status_code() . ":" . $session->status_detail()); } print"The object was added successfully \n";
#Search for the object
my @retrieved_objs = $session->search( object => "Infoblox::Grid::NamedACL", name => ".*"); my $object = $retrieved_objs[0];
unless ($object) { die("Search the object failed: ", $session->status_code() . ":" . $session->status_detail()); } print "Search the object found at least 1 matching entry\n";
#Get and modify the object
#Get the object through session my @retrieved_objs = $session->get( object => "Infoblox::Grid::NamedACL", name => "NACL" ); my $nacl = $retrieved_objs[0];
unless ($nacl) { die("Get the object failed: ", $session->status_code() . ":" . $session->status_detail()); } print"Retrieved the object successfully \n";
# Modify one of the attributes of selected object.
$nacl->comment("Modified object");
#Applying the changes $session->modify($nacl) or die("Modify the object failed", $session->status_code() . ":" . $session->status_detail()); print"The object was modified successfully \n";
#Remove the object
#Get the object through session my @retrieved_objs = $session->get( object => "Infoblox::Grid::NamedACL", name => "NACL" ); my $desired_nacl = $retrieved_objs[0];
unless ($desired_nacl) { die("Get the object failed: ", $session->status_code() . ":" . $session->status_detail()); } print"Retrieved the object successfully \n";
#Submit the object for removal $session->remove( $desired_nacl ) or die("Remove the object failed", $session->status_code() . ":" . $session->status_detail()); print"The object was removed successfully \n";
####PROGRAM ENDS####
Infoblox Inc. http://www.infoblox.com/
Infoblox::Session, Infoblox::DNS::TSIGKey, Infoblox::Grid::ExtensibleAttributeDef
Copyright (c) 2017 Infoblox Inc.