Class: Lumberg::Cpanel::Mysql
- 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
Attributes inherited from Whm::Base
Class Method Summary collapse
Instance Method Summary collapse
-
#accounts ⇒ Object
Public: List all of the MySQL users available to a cPanel account.
-
#backups ⇒ Object
Public: Retrieve a list of existing database backups.
-
#list(options = {}) ⇒ Object
Public: Retrieve a list of databases that belong to username.
-
#permissions(options = {}) ⇒ Object
Public: Retrieve a list of permissions that correspond to a specific user and database.
-
#remote_hosts ⇒ Object
Public: Retrieve a list of remote MySQL connection hosts.
-
#usernames_for_db(options = {}) ⇒ Object
Public: List users who can access a particular database.
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
6 |
# File 'lib/lumberg/cpanel/mysql.rb', line 6 def self.api_module; "MysqlFE"; end |
Instance Method Details
#accounts ⇒ Object
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 |
#backups ⇒ Object
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( = {}) perform_request({ api_function: 'listdbs' }.merge()) 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 ( = {}) perform_request({ api_function: 'userdbprivs' }.merge()) end |
#remote_hosts ⇒ Object
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( = {}) perform_request({ api_function: 'listusersindb' }) end |