Class: Lumberg::Cpanel::MysqlDb
- Defined in:
 - lib/lumberg/cpanel/mysql_db.rb
 
Overview
Public: Allows you to manage MySQL Databases, users and other related settings.
Instance Attribute Summary
Attributes inherited from Base
Attributes inherited from Whm::Base
Class Method Summary collapse
Instance Method Summary collapse
- 
  
    
      #add_db(options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Add a new MySQL database to a cPanel account.
 - 
  
    
      #add_host(options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Authorize a remote host to access a cPanel account’s MySQL users.
 - 
  
    
      #add_user(options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Create a new MySQL user.
 - 
  
    
      #add_user_db(options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Grant a user permission to access a cPanel account’s database.
 - 
  
    
      #check_db(options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Run a MySQL database check.
 - 
  
    
      #del_db(options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Remove a database from MySQL.
 - 
  
    
      #del_host(options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Remove host access permissions from MySQL.
 - 
  
    
      #del_user(options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Remove a user from MySQL.
 - 
  
    
      #del_user_db(options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Disallow a MySQL user from accessing a database.
 - 
  
    
      #init_cache(options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Refresh the cache of MySQL information.
 - 
  
    
      #number_of_dbs(options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Retrieve the number of database users an account has created.
 - 
  
    
      #repair_db(options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Run a MySQL database repair.
 - 
  
    
      #update_privs(options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Force an update of MySQL privileges and passwords.
 
Methods inherited from Base
Methods inherited from Whm::Base
Constructor Details
This class inherits a constructor from Lumberg::Cpanel::Base
Class Method Details
.api_module ⇒ Object
      5  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 5 def self.api_module; "Mysql"; end  | 
  
Instance Method Details
#add_db(options = {}) ⇒ Object
Public: Add a new MySQL database to a cPanel account.
options - Hash options for API call params (default: {}).
:dbname - String name of the MySQL database to add.
Returns Hash API response.
      13 14 15 16 17 18  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 13 def add_db( = {}) perform_request({ api_function: 'adddb', 'arg-0' => .delete(:dbname) }.merge(())) end  | 
  
#add_host(options = {}) ⇒ Object
Public: Authorize a remote host to access a cPanel account’s MySQL users.
options - Hash options for API call params (default: {})
:hostname - String IP address or hostname that should be provided access.
Returns Hash API response.
      163 164 165 166 167 168  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 163 def add_host( = {}) perform_request({ api_function: 'addhost', 'arg-0' => .delete(:hostname) }.merge(())) end  | 
  
#add_user(options = {}) ⇒ Object
Public: Create a new MySQL user.
options - Hash options for API call params (default: {}).
:username - String MySQL user to create.
:password - String password for the new MySQL user.
Returns Hash API respone.
      27 28 29 30 31 32 33  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 27 def add_user( = {}) perform_request({ api_function: 'adduser', 'arg-0' => .delete(:username), 'arg-1' => .delete(:password) }.merge(())) end  | 
  
#add_user_db(options = {}) ⇒ Object
Public: Grant a user permission to access a cPanel account’s database.
options - Hash options for API call params (default: {})
:dbname - String name of the database to allow the user to access.
:dbuser - String MySQL user who should be given access to the database.
:perms_list - A space-separated String containing a list of permissions
              to grant to the user
              (e.g. "all" or "alter drop create delete insert update lock" )
Returns Hash API respone.
      45 46 47 48 49 50 51 52  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 45 def add_user_db( = {}) perform_request({ api_function: 'adduserdb', 'arg-0' => .delete(:dbname), 'arg-1' => .delete(:dbuser), 'arg-2' => .delete(:perms_list) }.merge(())) end  | 
  
#check_db(options = {}) ⇒ Object
Public: Run a MySQL database check.
options - Hash options for API call params (default: {}).
:dbname - String name of the MySQL database to check.
Returns Hash API response.
      69 70 71 72 73 74  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 69 def check_db( = {}) perform_request({ api_function: 'checkdb', 'arg-0' => .delete(:dbname) }.merge(())) end  | 
  
#del_db(options = {}) ⇒ Object
Public: Remove a database from MySQL.
options - Hash options for API call params (default: {}).
:dbname - String name of the MySQL database to remove.
         This value must be prefixed with the cPanel username
         (e.g., cpuser_dbname).
Returns Hash API response.
      150 151 152 153 154 155  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 150 def del_db( = {}) perform_request({ api_function: 'deldb', 'arg-0' => .delete(:dbname) }.merge(())) end  | 
  
#del_host(options = {}) ⇒ Object
Public: Remove host access permissions from MySQL.
options - Hash options for API call params (default: {})
:host - String IP address or hostname that should be provided access.
Returns Hash API response.
      176 177 178 179 180 181  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 176 def del_host( = {}) perform_request({ api_function: 'delhost', 'arg-0' => .delete(:host) }.merge(())) end  | 
  
#del_user(options = {}) ⇒ Object
Public: Remove a user from MySQL.
options - Hash options for API call params (default: {})
:dbuser - String name of the MySQL user to remove.
          This value must be prefixed with the cPanel username.
          (e.g. cpuser_dbuser)
Returns Hash API response.
      135 136 137 138 139 140  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 135 def del_user( = {}) perform_request({ api_function: 'deluser', 'arg-0' => .delete(:dbuser) }.merge(())) end  | 
  
#del_user_db(options = {}) ⇒ Object
Public: Disallow a MySQL user from accessing a database.
options - Hash options for API call params (default: {})
:dbname - String MySQL database from which to remove the user's permissions.
:dbuser - String name of the MySQL user to remove.
Returns Hash API response.
      119 120 121 122 123 124 125  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 119 def del_user_db( = {}) perform_request({ api_function: 'deluserdb', 'arg-0' => .delete(:dbname), 'arg-1' => .delete(:dbuser) }.merge(())) end  | 
  
#init_cache(options = {}) ⇒ Object
Public: Refresh the cache of MySQL information. This includes users,
databases, routines and other related information.
options - Hash options for API call params (default: {})
Returns Hash API response.
      106 107 108 109 110  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 106 def init_cache( = {}) perform_request({ api_function: 'initcache' }.merge(())) end  | 
  
#number_of_dbs(options = {}) ⇒ Object
Public: Retrieve the number of database users an account has created.
Returns Hash API response.
      57 58 59 60 61  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 57 def number_of_dbs( = {}) perform_request({ api_function: 'number_of_dbs' }.merge(())) end  | 
  
#repair_db(options = {}) ⇒ Object
Public: Run a MySQL database repair.
options - Hash options for API call params (default: {}).
:dbname - String name of the MySQL database to repair.
Returns Hash API response.
      82 83 84 85 86 87  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 82 def repair_db( = {}) perform_request({ api_function: 'repairdb', 'arg-0' => .delete(:dbname) }.merge(())) end  | 
  
#update_privs(options = {}) ⇒ Object
Public: Force an update of MySQL privileges and passwords.
options - Hash options for API call params (default: {})
Returns Hash API response.
      94 95 96 97 98  | 
    
      # File 'lib/lumberg/cpanel/mysql_db.rb', line 94 def update_privs( = {}) perform_request({ api_function: 'updateprivs' }.merge(())) end  |