Class: Lumberg::Cpanel::Mysql

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

Overview

Public: Allows you to access information about an account's MySQL users, databases, and permissions

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


6
# File 'lib/lumberg/cpanel/mysql.rb', line 6

def self.api_module; "MysqlFE"; end

Instance Method Details

#accountsObject

Public: List all of the MySQL users available to a cPanel account

Returns Hash API response


20
21
22
# File 'lib/lumberg/cpanel/mysql.rb', line 20

def accounts
  perform_request({ api_function: 'listusers' })
end

#backupsObject

Public: Retrieve a list of existing database backups

Returns Hash API response


34
35
36
# File 'lib/lumberg/cpanel/mysql.rb', line 34

def backups
  perform_request({ api_function: 'listdbsbackup' })
end

#list(options = {}) ⇒ Object

Public: Retrieve a list of databases that belong to username

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

:regex - String regular expression to filter results (optional)

Returns Hash API response


13
14
15
# File 'lib/lumberg/cpanel/mysql.rb', line 13

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

#permissions(options = {}) ⇒ Object

Public: Retrieve a list of permissions that correspond to a specific user and database

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

:db - String database that corresponds to th user whose permission
      you wish to view
:username - String user whose permissions you wish to view

Returns Hash API response


59
60
61
# File 'lib/lumberg/cpanel/mysql.rb', line 59

def permissions(options = {})
  perform_request({ api_function: 'userdbprivs' }.merge(options))
end

#remote_hostsObject

Public: Retrieve a list of remote MySQL connection hosts

Returns Hash API response


27
28
29
# File 'lib/lumberg/cpanel/mysql.rb', line 27

def remote_hosts
  perform_request({ api_function: 'listhosts' })
end

#usernames_for_db(options = {}) ⇒ Object

Public: List users who can access a particular database

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

:db - String name of the database whose users you wish to review. Be
      sure to use Cpanel convention's full mysql database name, e.g:
      cpanelaccount_databasename

Returns Hash API response


46
47
48
# File 'lib/lumberg/cpanel/mysql.rb', line 46

def usernames_for_db(options = {})
  perform_request({ api_function: 'listusersindb' })
end