Class: Lumberg::Cpanel::ZoneEdit

Inherits:
Base show all
Defined in:
lib/lumberg/cpanel/zone_edit.rb

Overview

Public: This module allows users to modify their domains

Instance Attribute Summary

Attributes inherited from Base

#api_username

Attributes inherited from Whm::Base

#server

Instance Method Summary collapse

Methods inherited from Base

api_module, #initialize, #perform_request

Methods inherited from Whm::Base

#initialize, #setup_server

Constructor Details

This class inherits a constructor from Lumberg::Cpanel::Base

Instance Method Details

#create(options = {}) ⇒ Object

Public: Add an A, CNAME, or TXT record to a zone file, specified by line number

options - Hash options for API call params (default: {})

:domain - String addon domain for which yo wish to add an entry
:name - String name of the record, aka subdomain
:type - String type of the record you wish to add to the zone file.
        Acceptable values include A, CNAME or TXT
:txt  - String text you wish to contain in your TXT record. Required
        parameter when you specify "TXT" in the :type parameter
        (default: '')
:cname - String required parameter when you specify CNAME in the
         :type parameter (default: '')
:address - String ip address to map to the subdomain. (default: '')
:ttl - Integer time to live in seconds (default: 0)
:class - String class to be used for the record. Ordinarily this
         parameter is not required (default: '')

Returns Hash API response.


31
32
33
34
# File 'lib/lumberg/cpanel/zone_edit.rb', line 31

def create(options = {})
  options[:txtdata] = options.delete(:txt)
  perform_request({ api_function: 'add_zone_record' }.merge(options))
end

#edit(options = {}) ⇒ Object

Public: Edit an A, CNAME, or TXT record in a zone file, specified by line number. This function works nicely with “show” method to easily fetch line number and record information.

options - Hash options for API call params (default: {})

:domain - String domain that corresponds to the zone you wish to edit
:line - Integer line number of the zone file you wish to edit
:type - The type fo record you wish to add to the zone file.
        Acceptable values include A, CNAME or TXT. Each type of
        record requires a specific parameter
:txt  - String text you wish to contain in your TXT record. Required
        parameter when you specify "TXT" in the :type parameter
        (default: '')
:cname - String required parameter when you specify CNAME in the
         :type parameter (default: '')
:address - String ip address to map to the subdomain. (default: '')
:ttl - Integer time to live in seconds (default: 0)
:class - String class to be used for the record. Ordinarily this
         parameter is not required (default: '')

Returns Hash API response.


89
90
91
92
93
# File 'lib/lumberg/cpanel/zone_edit.rb', line 89

def edit(options = {})
  options[:Line]    = options.delete(:line)
  options[:txtdata] = options.delete(:txt)
  perform_request({ api_function: 'edit_zone_record' }.merge(options))
end

#listObject

Public: Retrieve a list of your account's zones and zone file contents.

Returns Hash API Response


8
9
10
# File 'lib/lumberg/cpanel/zone_edit.rb', line 8

def list
  perform_request({ api_function: 'fetchzones' })
end

#modifications_for(options = {}) ⇒ Object

Public: Retrieve a list of zone modifications for a specific domain.

options - Hash options for API call params (default: {})

:domain - String domain whose zone modifications you wish to view

Returns Hash API response.


128
129
130
# File 'lib/lumberg/cpanel/zone_edit.rb', line 128

def modifications_for(options = {})
  perform_request({ api_function: 'fetchzone_records' }.merge(options))
end

#remove(options = {}) ⇒ Object

Public: Remove lines from a DNS zone file. You may only remove A, TXT, and CNAME records with this function.

options - Hash options for API call params (default: {})

:domain - String domain that corresponds to the zone you wish to
          remove a line
:line - Integer line number of the zone file you wish to remove. Use
        "show" method to obtain the line number of a record

Returns Hash API response.


105
106
107
# File 'lib/lumberg/cpanel/zone_edit.rb', line 105

def remove(options = {})
  perform_request({ api_function: 'remove_zone_record' }.merge(options))
end

#reset(options = {}) ⇒ Object

Public: Revert a zone file to its original state.

options - Hash options for API call params (default: {})

:domain - String domain that corresponds to the zone file you wish to
          revert

Returns Hash API response


64
65
66
# File 'lib/lumberg/cpanel/zone_edit.rb', line 64

def reset(options = {})
  perform_request({ api_function: 'resetzone' })
end

#show(options = {}) ⇒ Object

Public: Show dns zone for a domain

options - Hash options for API call params (default: {})

:domain - String domain that corresponds to the zone file you wish to
          show
:get_custom_entries - Boolean parameter. Entering a value of "1" will
                      cause the function to return only non-essential
                      A and CNAME records. These will include www.*,
                      ftp.*, mail.* and localhost.* (default: '')
:keys - String parameter that may contain a serie of values, all of
        which act the same way. Each value searches the data
        structure, like a grep, for a single hash (line of the zone
        file). Acceptable values include: line, ttl, name, class,
        address, type, txtdata, preference and exchange.

Returns Hash API response.


52
53
54
55
# File 'lib/lumberg/cpanel/zone_edit.rb', line 52

def show(options = {})
  options[:customonly] = options.delete(:get_custom_entries)
  perform_request({ api_function: 'fetchzone' }.merge(options))
end

#show_domains(options = {}) ⇒ Object

Public: Retrieve a list of domains, created within cPanel, associated with your cPanel account.

options - Hash options for API call params (default: {})

:domain - String domain parameter which allows you to append one
          domain name to the end of the resulting output
          (default: '')

Returns Hash API response.


118
119
120
# File 'lib/lumberg/cpanel/zone_edit.rb', line 118

def show_domains(options = {})
  perform_request({ api_function: 'fetch_cpanel_generated_domains' })
end