Infoblox::DNS::Record::Alias - DNS Alias record object.


NAME

Infoblox::DNS::Record::Alias - DNS Alias record object.


DESCRIPTION

The Alias DNS resource record (RR) allows you to create typed aliases for standard DNS resource records which are resolved dynamically by an authoritative server. Unlike CNAME Alias can be created in the zone apex.

Note that you must specify only one view for the attribute 'views'.


CONSTRUCTOR

 my $alias = Infoblox::DNS::Record::Alias->new(
     name                  => $fqdn,                                                          # Required
     target_name           => $fqdn,                                                          # Required
     target_type           => 'A' | 'AAAA' | 'MX' | 'NAPTR' | 'PTR' | 'SPF' | 'SRV' | 'TXT',  # Required
     comment               => $string,                                                        # Optional / Default is empty
     disable               => 'true' | 'false'                                                # Optional / Default 'false'
     extattrs              => {$string => $extattr, ...},                                     # Optional / Default is undefined
     extensible_attributes => {$string => $string|$num, $string => [$string|$num, ...], ...}, # Optional / Default is undefined
     ttl                   => $num | undef,                                                   # Optional / Default is undefined
     views                 => [$View1],                                                       # Optional / Default is 'default' view
     creator               => 'STATIC',                                                       # Optional / Default is 'STATIC'
 );

You cannot set both extattrs and extensible_attributes attributes at the same time.


SESSION METHODS

This section describes all the methods in Infoblox::Session module that you can apply to the 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 object
 my $object = Infoblox::DNS::Record::Alias->new(
     name              => 'alias.domain.com',
     target_name       => 'target.com',
     target_type       => 'A',
     comment           => 'add Alias alias.domain.com',
     disable           => 'false',
     ttl               => '360',
     views             => [$view1],
 );
 #Submit for addition
 my $response = $session->add($object);

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 DNS Alias object:
  name                  - Optional. A host name in string format.
  view                  - Optional. The DNS view in which the Alias record is located. By default, all DNS views are searched. But if you omit this attribute and specify a zone, the appliance searches the 'default' view only.
  zone                  - Optional. A zone name in FQDN format.
  target_name           - Optional. A target name.
  target_type           - Optional. A target type.
  creator               - Optional. Record creator.
  extattrs              - Optional. A hash reference containing extensible attributes.
  extensible_attributes - Optional. A hash reference containing extensible attributes.
Example
 my @retrieved_objs = $session->get(
     object => 'Infoblox::DNS::Record::Alias',
     name   => 'alias.domain.com',
     view   => 'default' );
 #Get all DNS Alias records from the 'domain.com' zone of the default view
 my @retrieved_objs = $session->get(
     object => 'Infoblox::DNS::Record::Alias',
     zone   => 'domain.com',
     view   => 'default' );
 #Get all DNS Alias records with a given extensible attribute
 my @retrieved_objs = $session->get(
     object => 'Infoblox::DNS::Record::Alias',
     extensible_attributes => { 'Site' => 'Santa Clara' });

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 the following method to modify the comment.
 $object->comment('This is a modified comment');
 #Submit modification
 my $response = $session->modify($object);

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

Example
 #Get the objects with the same name
 my @retrieved_objs = $session->get(
     object => 'Infoblox::DNS::Record::Alias',
     name   => 'alias.domain.com',
     view   => 'default' );
 #Find the desired object from the retrieved list.
 my $desired_object = $retrieved_objs[0];
 #Submit for removal
 my $response = $session->remove($desired_object);

Infoblox::Session->search( )

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

Key References
 Apply the following attributes to search for a DNS Alias record object:
  name                  - Optional. A name in FQDN (Fully Qualified Domain Name) format (regular expression).
  target_name           - Optional. A target name (regular expression).
  target_type           - Optional. A target type.
  view                  - Optional. The DNS view in which the Alias record is located. By default, all DNS views are searched. But if you omit this attribute and specify a zone, the appliance searches the 'default' view only.
  zone                  - Optional. A zone name in FQDN format.
  comment               - Optional. A comment in string format (regular expression).
  creator               - Optional. Record creator.
  extattrs              - Optional. A hash reference containing extensible attributes.
  extensible_attributes - Optional. A hash reference containing extensible attributes.

For more information about searching extensible attributes, see Infoblox::Grid::ExtensibleAttributeDef/Searching Extensible Attributes.

Example
 #Search for all DNS Alias objects that match 'domain.com' in the default DNS view
 my @retrieved_objs = $session->search(
     object => 'Infoblox::DNS::Record::Alias',
     name   => 'domain\.com',
     view   => 'default' );
 #Search for all DNS Alias records in the 'domain.com' zone of the default view
 my @retrieved_objs = $session->search(
     object => 'Infoblox::DNS::Record::Alias',
     zone   => 'domain.com',
     view   => 'default' );
 #Search for all DNS Alias records with a given extensible attribute 'Site'
 my @retrieved_objs = $session->search(
    object => 'Infoblox::DNS::Record::Alias',
    extensible_attributes => { 'Site' => 'Santa Clara' });


METHODS

This section describes all the methods that you can use to configure and retrieve the attribute values of an Alias record.

comment( )

Use this method to set or retrieve the descriptive comment.

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

Parameter

Desired comment in string format with a maximum of 256 bytes.

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 value
 my $value = $object->comment();
 #Modify comment value
 $object->comment('Modifying the comment');

cloud_info( )

Use this method to retrieve cloud API related information for the Infoblox::DNS::Record::Alias object.

Parameter

None

Returns

The method returns the attribute value.

Example
 # Get cloud_info value
 my $value = $object->cloud_info();

creator( )

Use this method to set or retrieve the record creator.

Note that changing creator from or to 'SYSTEM' value is not allowed.

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

Paramter

The valid values are 'STATIC' and 'DYNAMIC'. The default value is 'STATIC'.

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 creator value
 my $value = $object->creator();
 #Modify creator value
 $object->creator('DYNAMIC');

disable( )

Use this method to set or retrieve the disable flag for a DNS record.

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

The default value for this field is false. The DNS record is enabled.

Parameter

Specify 'true' to set the disable flag or 'false' to deactivate/unset it.

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 disable value
 my $value = $object->disable();
 #Modify disable value
 $object->disable('true');

dns_name( )

Use this method to retrieve the name in punycode format. This is a read-only attribute.

Parameter

None

Returns

The method returns the attribute value.

Example
 # Get dns_name value
 my $value = $object->dns_name();

dns_target_name( )

Use this method to retrieve the target name in punycode format. This is a read-only attribute.

Parameter

None

Returns

The method returns the attribute value.

Example
 # Get dns_target_name value
 my $value = $object->dns_target_name();

extattrs( )

Use this method to set or retrieve the extensible attributes associated with a DNS Alias record object.

Parameter

Valid value is a hash reference containing the names of extensible attributes and their associated values ( Infoblox::Grid::Extattr objects ).

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 extattrs value
 my $value = $object->extattrs();
 #Modify extattrs value
 $object->extattrs({'Site' => $extattr1, 'Administrator' => $extattr2});

extensible_attributes( )

Use this method to set or retrieve the extensible attributes associated with a DNS Alias record.

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

Parameter

For valid values for extensible attributes, see Infoblox::Grid::ExtensibleAttributeDef/Extensible Attribute Values.

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 extensible_attributes value
 my $value = $object->extensible_attributes();
 #Modify extensible_attributes value
 $object->extensible_attributes({'Site' => 'Santa Clara', 'Administrator' => ['Peter', 'Tom']});

name( )

Use this method to set or retrieve the name.

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

The attribute value can be in unicode format.

Parameter

The name of the DNS Alias object in Fully Qualified Domain Name (FQDN) format. The name can have a maximum of 256 bytes.

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 value
 my $value = $object->name();
 #Modify name value
 $object->name('new.domain.com');

target_name( )

Use this method to set or retrieve the target name of the Alias.

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

The attribute value can be in unicode format.

Parameter

Target name in FQDN (Fully Qualified Domain Name) format. The FQDN consists of the hostname followed by the domain name (example: abc.com). A hostname can have a maximum of 256 bytes.

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 target_name
 my $target_name = $alias->target_name();
 #Modify target_name
 $alias->target_name("alias.domain.com");

target_type( )

Use this method to set or retrieve the alias target type.

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

Paramter

The valid values are 'A', 'AAAA', 'MX', 'NAPTR', 'PTR', 'SPF', 'SRV' and 'TXT'.

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 target_type value
 my $value = $object->target_type();
 #Modify target_type value
 $object->target_type('A');

ttl( )

Use this method to set or retrieve the Time to Live (TTL) value.

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

The default value is undefined which indicates that the record inherits the TTL value of the zone.

Specify a TTL value to override the TTL value at the zone level.

Parameter

A 32-bit integer (range from 0 to 4294967295) that represents the duration in seconds to cache the record. Zero indicates that the record should not be cached.

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 ttl value
 my $value = $object->ttl();
 #Modify ttl value
 $object->ttl(1800);
 #Un-override ttl
 $object->ttl(undef);

views( )

Use this method to set or retrieve the view of a Alias record.

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

The default value is the 'default' view, which means that the Alias record is located under the default view.

Parameter

Array reference of defined Infoblox::DNS::View objects.

Note that the array size must be 1.

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 views value
 my $value = $object->views();
 #Modify views value
 $object->views([$view1]);

zone( )

Use this method to retrieve the zone name of a DNS Alias record. This is a read-only attribute.

Parameter

None

Returns

The method returns the attribute value.

Example
 #Get zone value
 my $zone = $object->zone();


SAMPLE CODE

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

#Preparation prior to a DNS Alias record insertion

 #PROGRAM STARTS: Include all the modules that will be used
 use strict;
 use Infoblox;
 #Create a session on 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";
 #Create the zone prior to a Alias record insertion
 my $zone = Infoblox::DNS::Zone->new(name => "domain.com");
 unless ($zone) {
        die("Construct zone failed: ",
                Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Zone object created successfully\n";
 #Verify if the zone exists
 my $object = $session->get(object => "Infoblox::DNS::Zone", name => "domain.com");
 unless ($object) {
        print "Zone does not exist on the server, safe to add the zone\n";
        $session->add($zone)
                or die("Add zone failed: ",
                                $session->status_code() . ":" . $session->status_detail());
 }
 print "Zone added successfully\n";

#Create a DNS Alias record

 my $alias = Infoblox::DNS::Record::Alias->new(
                name              => "alias.domain.com",
                target_name       => "target.com",
                target_type       => "A",
                comment           => "add Alias alias.domain.com",
                );
 unless ($alias) {
        die("Construct DNS record Alias failed: ",
                Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 #Add the DNS Alias record object to the Infoblox appliance through a session
 $session->add($alias)
        or die("Add record Alias failed: ",
                        $session->status_code() . ":" . $session->status_detail());
 print "DNS Alias object is added to the server successfully\n";

#Search for a specific DNS Alias record

 #Search all Alias records in the zone that matches "domain.com"
 my @retrieved_objs = $session->search(
                object => "Infoblox::DNS::Record::Alias",
                name   => 'domain\.com'
                );
 my $object = $retrieved_objs[0];
 unless ($object) {
        die("Search record Alias failed: ",
                $session->status_code() . ":" . $session->status_detail());
 }
 print "Search a DNS Alias object found at least 1 matching entry\n";
 #Search all Alias records with names that start with "alias" and end with "domain.com"
 my @retrieved_objs = $session->search(
                object => "Infoblox::DNS::Record::Alias",
                name   => '^alias.*\.domain\.com\$'
                );
 my $object = $retrieved_objs[0];
 unless ($object) {
        die("Search record Alias failed: ",
                $session->status_code() . ":" . $session->status_detail());
 }
 print "Search a DNS Alias object using regexp found at least 1 matching entry\n";

#Get and modify a DNS Alias record

 #Get an Alias record through the session
 my @retrieved_objs = $session->get(
                object => "Infoblox::DNS::Record::Alias",
                name   => "alias.domain.com"
                );
 my $object = $retrieved_objs[0];
 unless ($object) {
        die("Get record Alias failed: ",
                $session->status_code() . ":" . $session->status_detail());
 }
 print "Get a DNS Alias object found at least 1 matching entry\n";
 #Modify one of the attributes of the specified Alias record
 $object->comment("this is new comment string");
 #Apply the changes
 $session->modify($object)
        or die("Modify record Alias failed: ",
                $session->status_code() . ":" . $session->status_detail());
 print "DNS Alias object modified successfully \n";

#Remove a DNS Alias record

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


AUTHOR

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


SEE ALSO

Infoblox::Session->add(), Infoblox::Session->get(), Infoblox::Session->modify(), Infoblox::Session->remove(), Infoblox::Session->search(), Infoblox::Session, Infoblox::DNS::View, Infoblox::DNS::Zone


COPYRIGHT

Copyright (c) 2017 Infoblox Inc.