cPanel/Postgresql
cPanel module

Postgresql

14 functions, invoked through the cpanel_uapi tool.

scope cpanel:uapi
Call any function with cpanel_uapi(service_id, module="Postgresql", function, params). Live availability depends on the cPanel features JetHost has enabled on your account — call list_cpanel_operations to see what is active.

create_database GET#

Create PostgreSQL database

This function creates a PostgreSQL® database.

Important:

When you disable the PostgreSQL role, the system disables this function.

namestringRequired
The database's name. Note: If database prefixing is enabled, this parameter must include the database prefix for the account.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

create_user GET#

Create PostgreSQL user

This function creates a PostgreSQL® database user.

Important:

When you disable the PostgreSQL role, the system disables this function.

namestringRequired
The database user's name. Note: If database prefixing is enabled, this parameter must include the database prefix for the account.
passwordstringRequired
The new user's password.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

delete_database GET#

Delete PostgreSQL database

This function deletes a PostgreSQL® database.

Important:

When you disable the Postgres role, the system disables this function.

namestringRequired
The database's name.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

delete_user GET#

Delete PostgreSQL user

This function deletes a PostgreSQL® user.

Important:

When you disable the PostgreSQL role, the system disables this function.

namestringRequired
The PostgreSQL user's name.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

get_restrictions GET#

Return PostgreSQL name length restrictions

This function retrieves the PostgreSQL® user and database name length restrictions.

Important:

When you disable the PostgreSQL role, the system disables this function.

No parameters.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

max_database_name_lengthinteger
The maximum length of a database name.
max_username_lengthinteger
The maximum length of a database username.
prefixstring
If database prefixing is enabled, this return outputs the database prefix. A valid string up to eight characters and an underscore (_).

grant_all_privileges GET#

Enable all user privileges on PostgreSQL database

This function grants all privileges for a PostgreSQL® database to a database user.

Important:

When you disable the PostgreSQL role, the system disables this function.

databasestringRequired
The database's name. Note If database prefixing is enabled, this value must include the database prefix for the account.
userstringRequired
The database user's name. Note If database prefixing is enabled, this value must include the database prefix for the account.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

list_databases GET#

Return PostgreSQL databases

This function lists an account's PostgreSQL® databases.

Important:

When you disable the Postgres role, the system disables this function.

No parameters.

Response — normalized as { ok, data, errors[], warnings[] }; data is an array of:

databasestring
The database name.
disk_usageinteger
The disk space that the database uses, in bytes.
usersarray<string>
An array of database usernames. Note: If no users exist on a database, the function returns an empty array

list_users GET#

Return PostgreSQL users

This function lists an account's PostgreSQL® database users.

Important:

When you disable the PostgreSQL role, the system disables this function.

No parameters.

Response — normalized as { ok, data, errors[], warnings[] }; data is an array of:

An array of strings which are PostgreSQL database usernames.

rename_database GET#

Update PostgreSQL database name

This function renames a PostgreSQL® database.

Important:

When you disable the PostgreSQL role, the system disables this function.

newnamestringRequired
The database's new name. Note: If database prefixing is enabled, this parameter must include the database prefix for the account.
oldnamestringRequired
The database's current name. Note: If database prefixing is enabled, this parameter must include the database prefix for the account.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

rename_user GET#

Update PostgreSQL username

This function renames a PostgreSQL® database user.

Important:

When you disable the PostgreSQL role, the system disables this function.

newnamestringRequired
The database user's new name. Note: If database prefixing is enabled, this parameter must include the database prefix for the account.
oldnamestringRequired
The database user's current name. Note: If database prefixing is enabled, this parameter must include the database prefix for the account.
passwordstringRequired
The database user's new password.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

rename_user_no_password GET#

Update PostgreSQL username without password

This function renames a PostgreSQL® database user.

Warning:

  • If you rename a PostgreSQL user, you must set the password for the database user. This is required because of the md5 hash that PostgreSQL creates to store user passwords.
  • We strongly recommend that you use the Postgresql::rename_user function instead of this one.

Important:

When you disable the PostgreSQL role, the system disables this function.

newnamestringRequired
The database user's new name. Note: If database prefixing is enabled, this parameter must include the database prefix for the account.
oldnamestringRequired
The database user's current name. Note: If database prefixing is enabled, this parameter must include the database prefix for the account.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

revoke_all_privileges GET#

Remove PostgreSQL user privileges

This function revokes all privileges for a PostgreSQL® database from a database user.

Important:

When you disable the PostgreSQL role, the system disables this function.

databasestringRequired
The database's name. Note If database prefixing is enabled, this value must include the database prefix for the account.
userstringRequired
The database user's name. Note If database prefixing is enabled, this value must include the database prefix for the account.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

set_password GET#

Update PostgreSQL user password

This function changes a PostgreSQL® database user's password.

Important:

When you disable the Postgres role, the system disables this function.

passwordstringRequired
The user's new password.
userstringRequired
The database user's name. Note: If database prefixing is enabled, this parameter must include the database prefix for the account.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

update_privileges GET#

Update PostgreSQL® privileges

This function synchronizes PostgreSQL® database user privileges on an account.

Some versions of PostgreSQL are ANSI SQL-92 compliant and do not support recursive grants, wildcard grants, or future grants. If you use phpPgAdmin, or manually create new tables, and you want multiple PostgreSQL users to access your PostgreSQL tables, you may either call this API function or click _Synchronize Grants_ in the _PostgreSQL Databases_ interface (_Home >> Databases >> PostgreSQL Databases_) after you add a table.

Important:

When you disable the PostgreSQL role, the system disables this function.

No parameters.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.