Infoblox::Grid::PersonalSmartFolder - Personal Smart Folder object.


NAME

Infoblox::Grid::PersonalSmartFolder - Personal Smart Folder object.


DESCRIPTION

A Personal Smart Folder object is used for data organization.


CONSTRUCTOR

 my $group = Infoblox::Grid::PersonalSmartFolder->new(
     name                => $string,                                                              #Required
     comment             => $string,                                                              #Optional / Default is undefined
     group_bys           => [$GroupbyItem1, $GroupbyItem2],                                       #Optional / Default is undefined
     query_items         => [$QueryItem1, $QueryItem2],                                           #Optional / Default is undefined
 );


SESSION METHODS

This section describes all the methods in the Infoblox::Session module that you can apply to a Personal Smart Folder object.

Infoblox::Session->add( )

Use this method to add an object to the Infoblox appliance. See Infoblox::Session->add() for parameters and return values.

Example
 #Construct the QueryItem in-memory object
 my $query_item1 = Infoblox::Grid::SmartFolder::QueryItem->new(
     name                 => "location",
     operator             => "eq",
     value                => "Santa Clara",
 );
 #Construct the PersonalSmartFolder object
 my $group_by_state = Infoblox::Grid::SmartFolder::GroupBy->new(
                                                                enable_grouping => 'true',
                                                                value => "State",
                                                                value_type => "EXTATTR",
                                                               );
 my $smart_folder = Infoblox::Grid::PersonalSmartFolder->new(
     name                 => "smartfolder1",
     comment              => "personal smart folder",
     group_bys            => [$group_by_state],
     query_items          => [$query_item1],
 );
 # Submit for addition
 my $response = $session->add( $smart_folder );

Infoblox::Session->get( )

Use this method to retrieve all the matching objects from the Infoblox appliance. See Infoblox::Session->get() for parameters and return values.

Key References
 Apply the following attributes to get a specific PersonalSmartFolder object:
  name      - Required. PersonalSmartFolder name in string format.
  comment   - Optional. Comment in string format.
Example
 my @retrieved_objs = $session->get(
     object     => "Infoblox::Grid::PersonalSmartFolder",
     name       => "smartfolder1" );

Infoblox::Session->modify( )

Use this method to modify an object in the Infoblox appliance. See Infoblox::Session->modify() for parameters and return values.

Example
 # Use this method to modify the comment.
 $smart_folder->comment("This is a modified comment");
 # Submit modification
 my $response = $session->modify( $smart_folder );

Infoblox::Session->remove( )

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, use get() or search() to retrieve the specific object first, and then submit this object for removal.

Example
 # Get the PersonalSmartFolder objects using a name
 my @retrieved_objs = $session->get(
     object     => "Infoblox::Grid::PersonalSmartFolder",
     name       => "smartfolder1" );
 # find the desired object from the retrieved list.
 my $desired_smart_folder = $retrieved_objs[0];
 # Submit for removal
 my $response = $session->remove( $desired_smart_folder );

Infoblox::Session->search( )

Use this method to search for Personal Smart Folder objects in the Infoblox appliance. See Infoblox::Session->search() for parameters and return values.

Key References
 Apply the following attributes to search for a specific PersonalSmartFolder object:
  name      - Optional. PersonalSmartFolder name in string format (regular expression).
  comment   - Optional. Comment in string format (regular expression).
Example
 # search for all PersonalSmartFolder objects that start with "smartfolder"
 my @retrieved_objs = $session->search(
     object => "Infoblox::Grid::PersonalSmartFolder",
     name   => "smartfolder.*" );


METHODS

This section describes all the methods that you can use to set and retrieve the attribute values of a PersonalSmartFolder object.

comment( )

Use this method to set or retrieve the comment.

Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.

Parameter

Pertinent information about the personal smart folder. Comment in string format with a maximum of 256 bytes. The default value is undefined.

Returns

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.

Example
 #Get comment
 my $comment = $smart_folder->comment();
 #Modify comment
 $smart_folder->comment("This is the modified comment for smartfolder1");

group_bys( )

Use this method to set or retrieve the group_bys value.

Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.

Parameter

The valid value is an array reference that contains Infoblox::Grid::SmartFolder::GroupBy object(s). The default value is undefined.

Returns

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.

Example
 my $group_by_state = Infoblox::Grid::SmartFolder::GroupBy->new(
                                                             enable_grouping => 'true',
                                                             value => "State",
                                                             value_type => "EXTATTR",
                                                            );
 #Get group_by value
 my $group_by = $smart_folder->group_by();
 #Modify group_by value
 $smart_folder->group_bys([$group_by_state]);

name( )

Use this method to set or retrieve the name of a personal smart folder.

Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.

Parameter

Text with the name of the personal smart folder.

Returns

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.

Example
 #Get name
 my $name = $smart_folder->name();

query_items( )

Use this method to set or retrieve the query items. If query items are not specified when you add() a smart folder, the server automatically assigns a default query item for the smart folder. This default query item is "type=Network/Zone/Range/Member". This ensures that objects are included in searches for these 4 types, by default. When you modify() a smart folder, the server keeps the query items provided by the client and does not add the default items.

Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.

Parameter

The valid value is an array reference that contains Infoblox::Grid::SmartFolder::QueryItem object(s). The default value is undefined.

Returns

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.

Example
 #Get query items
 my $query_items = $smart_folder->query_items();
 #Modify query items
 my $query_item1 = Infoblox::Grid::SmartFolder::QueryItem->new(
     name                 => "location",
     operator             => "eq",
     value                => "Santa Clara",
 );
 $smart_folder->query_items([$query_items1]);


SAMPLE CODE

The following sample code demonstrates the different functions that can be applied to an object, such as add, search, modify, and remove. This sample also includes error handling for the operations.

#Preparation prior to an PersonalSmartFolder object insertion

 #PROGRAM STARTS: Include all the modules that will be used
 use strict;
 use Infoblox;
 #Create a session to the Infoblox appliance
 my $session = Infoblox::Session->new(
                master   => "192.168.1.2", #appliance host ip
                username => "admin",       #appliance user login
                password => "infoblox"     #appliance password
                );
 unless ($session) {
        die("Construct session failed: ",
                Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Session created successfully\n";
 # Add a network with extensible attributes
 my %extensible_attributes=(
     'Region' => 'Santa Clara County',
     'Country' => 'USA',
     'State' => 'California',
     'Site' => 'Santa Clara',
     'Building' => 'HQ',
     'VLAN' => '1',
 );
 my $network = Infoblox::DHCP::Network->new(
     network => "10.0.0.0/24",
     extensible_attributes => \%extensible_attributes,
 );
 unless ($network) {
     die("Construct Network failed: ",
         Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Network created successfully\n";
 $session->add($network)
     or die("Add Network object failed: ",
     $session->status_code() . ":" . $session->status_detail());
 print "Network object added to server successfully\n";

#Create a PersonalSmartFolder object

 my $query_item = Infoblox::Grid::SmartFolder::QueryItem->new(
     name                     => "Country",
     is_extensible_attribute  => "true",
     operator                 => "eq",
     value                    => "USA",
 );
 unless ($query_item) {
     die("Construct query item object failed: ",
         Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Smart folder query item object created successfully\n";
 my $smart_folder = Infoblox::Grid::PersonalSmartFolder->new(
     name                     => "my_folder_personal",
     comment                  => "my personal folder",
     query_items              => [$query_item],
 );
 unless ($smart_folder) {
     die("Construct personal smart folder object failed: ",
         Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Smart folder object created successfully\n";
 #Add the PersonalSmartFolder object to the Infoblox appliance through a session
 $session->add($smart_folder)
     or die("Add PersonalSmartFolder object failed: ",
     $session->status_code() . ":" . $session->status_detail());
 print "PersonalSmartFolder object added to server successfully\n";

#Search for a PersonalSmartFolder

 my @retrieved_objs = $session->search(
     object => "Infoblox::Grid::PersonalSmartFolder",
     name   => "my_folder.*"
 );
 my $object = $retrieved_objs[0];
 unless ($object) {
     die("Search for a PersonalSmartFolder object failed: ",
         $session->status_code() . ":" . $session->status_detail());
 }
 print "Search for a PersonalSmartFolder object found at least 1 matching entry\n";

#Get and modify a PersonalSmartFolder object

 #Get the PersonalSmartFolder object from Infoblox appliance through a session
 my @retrieved_objs = $session->get(
     object => "Infoblox::Grid::PersonalSmartFolder",
     name   => "my_folder_personal"
 );
 my $object = $retrieved_objs[0];
 unless ($object) {
     die("Get PersonalSmartFolder object failed: ",
         $session->status_code() . ":" . $session->status_detail());
 }
 print "Get PersonalSmartFolder object found at least 1 matching entry\n";
 #Modify the PersonalSmartFolder object
 $object->name("my_folder_personal_renamed");
 $object->comment("modified personal smart folder");
 #Apply the changes.
 $session->modify($object)
     or die("Modify PersonalSmartFolder object failed: ",
     $session->status_code() . ":" . $session->status_detail());
 print "PersonalSmartFolder object modified successfully \n";

#Remove a PersonalSmartFolder object

 #Get the PersonalSmartFolder object through the session
 my @retrieved_objs = $session->get(
     object => "Infoblox::Grid::PersonalSmartFolder",
     name   => "my_folder_personal_renamed"
 );
 my $object = $retrieved_objs[0];
 unless ($object) {
     die("Get PersonalSmartFolder object failed: ",
         $session->status_code() . ":" . $session->status_detail());
 }
 print "Get PersonalSmartFolder object found at least 1 matching entry\n";
 #Submit the object for removal
 $session->remove($object)
     or die("Remove PersonalSmartFolder object failed: ",
     $session->status_code() . ":" . $session->status_detail());
 print "PersonalSmartFolder object removed successfully \n";

#Cleanup

 #Get the Network object through the session
 my @retrieved_objs = $session->get(
     object  => "Infoblox::DHCP::Network",
     network => "10.0.0.0/24"
 );
 my $object = $retrieved_objs[0];
 unless ($object) {
     die("Get Network object failed: ",
         $session->status_code() . ":" . $session->status_detail());
 }
 print "Get Network object found at least 1 matching entry\n";
 #Submit the object for removal
 $session->remove($object)
     or die("Remove Network object failed: ",
     $session->status_code() . ":" . $session->status_detail());
 print "Network object removed successfully \n";
 ####PROGRAM ENDS####


AUTHOR

Infoblox Inc. http://www.infoblox.com/


SEE ALSO

Infoblox::Grid::SmartFolderChildren, Infoblox::Grid::PersonalSmartFolder, Infoblox::Session->add(), Infoblox::Session->get(), Infoblox::Session->modify(), Infoblox::Session->remove(), Infoblox::Session->search(),Infoblox::Session


COPYRIGHT

Copyright (c) 2017 Infoblox Inc.