Setting Default Database Server
A default database server manages all databases of the corresponding type. Only one default database server for each type of databases is available in Plesk. Use the set-default operation to set a database server as default.
Request Packet Structure
A request XML packet setting a default database server includes the set-default operation node:
<packet>
<db_server>
<set-default>
...
</set-default>
</db_server>
</packet>
The set-default node has the following graphical representation:
Note: The interactive schema navigator for all request packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_input.svg.
- The id node is required. It specifies the remote database server ID. Data type: integer.
- The type node is required. If specified, the local database server will be set as default for managing the databases of the specified type. Data type: string. Allowed values: mysql | postgresql | mssql.
Note: You can set only one default database server for each type of databases.
Remarks
You can set multiple database servers as default in a single packet. Add as many set-default operations as the number of database servers which status is to be changed.
<db_server>
<set-default>
...
</set-default>
...
<set-default>
...
</set-default>
</db_server>
Note: When creating request packets, put nodes and elements in the order they follow in the packet structure.
Response Packet Structure
The set-default node of the output XML packet is structured as follows:
Note: The interactive schema navigator for all response packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_output.svg.
- The result node is required. It wraps the response retrieved
from the server. Data type: DatabaseServerResultType
(
database_output.xsd
). - The status node is required. It specifies the execution status of the set-default operation. Data type: string. Allowed values: ok | error.
- The errcode node is optional. Is returns the error code if the set-default operation fails. Data type: integer.
- The errtext node is optional. It returns the error message if the set-default operation fails. Data type: string.
- The id node is optional. If the set-default operation succeeds and ID was specified in the request packet, it returns the ID of the database server. Data type: integer.
Samples
Changing status of a database server
Upon supposition that the type of remote database server with ID 1 is mysql, the following request packet sets the database server as default for managing MySQL databases.
<packet>
<db_server>
<set-default>
<id>1</id>
</set-default>
</db_server>
</packet>
Response:
<packet>
<db_server>
<set-default>
<result>
<status>ok</status>
<id>1</id>
</result>
</set-default>
</db_server>
</packet>
If the database server with ID 1 was not found on the server, the response looks as follows:
<packet>
<db_server>
<set-default>
<result>
<status>error</status>
<errcode>1013</errcode>
<errtext>Database server does not exist.</errtext>
</result>
</set-default>
</db_server>
</packet>
Changing status of multiple database servers
This packet sets the remote database server with ID 1 and local Microsoft SQL database server as default for MySQL and Microsoft SQL databases correspondingly.
<packet>
<db_server>
<set-default>
<id>1</id>
</set-default>
<set-default>
<type>mssql</type>
</set-default>
</db_server>
</packet>
Response:
<packet>
<db_server>
<set-default>
<result>
<status>ok</status>
<id>1</id>
</result>
</set-default>
<set-default>
<result>
<status>ok</status>
</result>
</set-default>
</db_server>
</packet>