Class: Lumberg::Cpanel::Redirect

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

Overview

Public: Allows users to create and manage redirects

Instance Attribute Summary

Attributes inherited from Base

#api_username

Attributes inherited from Whm::Base

#server

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #perform_request

Methods inherited from Whm::Base

#initialize, #setup_server

Constructor Details

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

Class Method Details

.api_moduleObject


5
# File 'lib/lumberg/cpanel/redirect.rb', line 5

def self.api_module; "Mime"; end

Instance Method Details

#list(options = {}) ⇒ Object

Public: List redirects parsed from your various .htaccess files in human-readable form

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

:regex - String value to filter results by applying perl regurlar
         expressions to the "sourceurl" output key, and accepts a
         simple string also (default: '')

Returns Hash API response


16
17
18
# File 'lib/lumberg/cpanel/redirect.rb', line 16

def list(options = {})
  perform_request({ api_function: 'listredirects' }.merge(options))
end

#show(options = {}) ⇒ Object

Public: This function returns either the domain name entered or '** All Public Domains **'.

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

:domain - String value. If a domain name is entered, it will be
          returned. If this is set to '.*', '** All Public Domains **'
          will be returned. (default: '')
:url - String value. If a url is entered, it will be returned. If this
       is set to '.*' or '(.*)', '** All Requests **' will be
       returned (default: '')

Returns Hash API response


32
33
34
35
36
37
38
39
# File 'lib/lumberg/cpanel/redirect.rb', line 32

def show(options = {})
  if options[:domain] && options[:url]
    raise ArgumentError,
      "#{self.class.name}##{__method__} cannot accept both `:url` and `:domain`"
  end
  function = options[:domain].present? ? 'redirectname' : 'redirecturlname'
  perform_request({ api_function: function }.merge(options))
end