Infoblox::DNS::Record::NS - DNS NS record object


NAME

Infoblox::DNS::Record::NS - DNS NS record object


DESCRIPTION

An NS record identifies an authoritative DNS server for a domain. Each authoritative DNS server must have an NS record. The appliance automatically creates an NS record when you assign a grid member as the primary server for a zone. You can manually create NS records for other zones.

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


CONSTRUCTOR

 my $ns = Infoblox::DNS::Record::NS->new(
     name                => $name,                    #Required
     nameserver          => $nameserver,              #Required
     addresses           => [$ns1, $ns2, ...],        #Required
     ms_delegation_name  => $name,                    #Optional
     views               => [$View1]                  #Optional / Default is "default" view
 );


SESSION METHODS

This section describes all the methods in Infoblox::Session module that you can apply to a DNS NS Record 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 an object
 my $nsrecord = Infoblox::DNS::Record::NS->new(
     nameserver => "ns1.server.isp.org",
     name       => "domain.com",
     addresses  => [$ns1, $ns2],
 );
 # Submit for addition
 my $response = $session->add( $nsrecord );

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 NS Record object:
  name        - Optional.  A domain name in FQDN (Fully Qualified Domain Name) format.
  nameserver  - Optional.  A domain name in FQDN (Fully Qualified Domain Name) format.
  view        - Optional.  The DNS view in which the NS record is located. By default, all DNS views are searched.
Example
  my @retrieved_objs = $session->get(
     object    => "Infoblox::DNS::Record::NS",
     name      => "domain.com",
     view      => "default" );

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 method to modify the addresses.
 $nsrecord->addresses([$ns3]);
 # Submit modification
 my $response = $session->modify( $nsrecord );

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

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

Infoblox::Session->search( )

Use this method to search for DNS NS Record 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 NS Record object:
  name          - Optional. A domain name in FQDN (Fully Qualified Domain Name) format (regular expression).
  nameserver    - Optional. A domain name in FQDN (Fully Qualified Domain Name) format (regular expression).
  view          - Optional. The DNS view in which the NS record is located. By default, all DNS views are searched.
Example
 # search for all DNS NS objects that match "domain.com" in the default DNS view
     my @retrieved_objs = $session->search(
     object => "Infoblox::DNS::Record::NS",
     name   => 'domain\.com',
     view   => "default" );


METHODS

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

cloud_info( )

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

Parameter

None

Returns

The method returns the attribute value.

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

creator( )

Use this method to retrieve the NS record creator. This is a read-only attribute.

Parameter

None

Returns

The method returns the attribute value.

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

dns_name( )

Use this method to retrieve the domain name, in punycode format, of the zone to be redirected. This is a read-only attribute.

Parameter

None

Returns

The method returns the attribute value.

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

ms_delegation_name( )

Use this method to set or retrieve the ms_delegation_name field of the NS record. This method can be used if the primary server of the zone is a Microsoft (r) server. If this NS record is for a subzone zone, it will be the subzone name.

Parameter

A subzone name.

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
 #Getting ms_delegation_name
 my $ms_delegation_name = $nsrecord->ms_delegation_name();
 # Modifying ms_delegation_name (the full FQDN of the zone is "sub.test.com")
 $nsrecord->ms_delegation_name("sub");

last_queried( )

Use this method to retrieve the time when the associated record was last queried. This is a read-only attribute.

Parameter

None

Returns

The method returns the attribute value. The number of seconds that have elapsed since January 1st, 1970 UTC.

Example
 #Get last_queried
 my $last_queried = $nsrecord->last_queried();

name( )

Use this method to set or retrieve the domain name of the zone to be redirected.

The attribute value can be in unicode format.

Parameter

A domain name in FQDN format.

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
 #Getting name
 my $name = $nsrecord->name();
 # Modifying name
 $nsrecord->name("domain.com");

nameserver( )

Use this method to set or retrieve the domain name of an authoritative server for the redirected zone.

Parameter

A domain name in FQDN format.

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
 #Getting nameserver
 my $nameserver = $nsrecord->nameserver();
 # Modifying nameserver
 $nsrecord->nameserver("ns1.server.isp.org");

addresses( )

Use this method to set or retrieve the IP addresses of the name servers associated with the NS record.

Parameter

The valid value is an array reference that contains Infoblox::DNS::Nameserver::Address 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
 #Getting addresses
 my $nslist = $nsrecord->addresses();
 # Modifying addresses
 $nsrecord->addresses([$ns1, $ns2]);

views( )

Use this method to specify or retrieve the DNS view of the NS 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 the NS record is associated with a zone in the system-defined 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
 my $ref_views = $nsrecord->views();
 #Modify views, list of Infoblox::DNS::View objects
 $nsrecord->views([$view1]);


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 a DNS NS record 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",
     username => "admin",
     password => "infoblox"
 );
 unless ($session) {
    die("Construct session failed: ",
        Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Session created successfully\n";
 #Create the zone prior to NS 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 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 NS record

 my $ns1 = Infoblox::DNS::Nameserver::Address->new(
                                                           address  => '10.0.0.1',
                                                   auto_create_ptr => 'false'
                                                   );
 my $ns2 = Infoblox::DNS::Nameserver::Address->new(
                                                   address         => '10.0.0.2',
                                                   );
  #Construct a DNS NS object
   my $nsrecord = Infoblox::DNS::Record::NS->new(
     nameserver => "ns1.server.isp.org",
     name       => "domain.com",
     addresses  => [$ns1, $ns2],
   );
 unless ($nsrecord) {
    die("Construct DNS record NS failed: ",
        Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "DNS NS object created successfully\n"; #Add the DNS NS record object to Infoblox appliance through a session
 $session->add($nsrecord)
     or die("Add record NS failed: ",
            $session->status_code() . ":" . $session->status_detail());
 print "DNS NS object added to server successfully\n";

#Search for a specific DNS NS record

 #Search all NS records that match "domain.com"
 my @retrieved_objs = $session->search(
     object     => "Infoblox::DNS::Record::NS",
     nameserver => "ns1.server.isp.org",
     name       => 'domain\.com'
 );
 my $object = $retrieved_objs[0];
 unless ($object) {
     die("Search record NS failed: ",
         $session->status_code() . ":" . $session->status_detail());
 }
 print "Search DNS NS object found at least 1 matching entry\n";

#Get and modify a DNS NS record

 #Get NS record through the session
 my  @retrieved_objs = $session->get(
     object     => "Infoblox::DNS::Record::NS",
     nameserver => "ns1.server.isp.org",
     name       => "domain.com",
 );
 my $object = $retrieved_objs[0];
 unless ($object) {
     die("Get record NS failed: ",
         $session->status_code() . ":" . $session->status_detail());
 }
 print "Get DNS NS object found at least 1 matching entry\n";
 #Modify one of the attributes of the specified NS record
 $object->addresses([$ns1]);
 #Apply the changes
 $session->modify($object)
     or die("Modify record NS failed: ",
            $session->status_code() . ":" . $session->status_detail());
 print "DNS NS object modified successfully \n";

#Remove a DNS NS record

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


AUTHOR

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


SEE ALSO

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


COPYRIGHT

Copyright (c) 2017 Infoblox Inc.