Creating Protected Directory
Use the add operation to add a new protected directory.
Request Packet Structure
A request XML packet adding a new protected directory includes the add operation node:
<packet>
<protected-dir>
<add>
...
</add>
</protected-dir>
</packet>
The add node is presented by the ProtectedDirAddInput type
(protected_dir.xsd
), and its graphical representation is as follows:
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 site-id node is required. It specifies the site on which the protected directory is created. Data type: integer.
- The name node is required. It specifies the protected directory name. Data type: string.
- The header node is optional. It specifies the protected directory header. It is the message that is displayed to a user when he tries to access the protected directory. Data type: string.
- The location node is optional. It specifies protected directory properties. Data type: complex.
Note: The location node can be specified only in Plesk for Linux/Unix. The SSL/TLS support parameter is inherited from settings of the site: If it is enabled on the site, it will also be enabled for the protected directory. If the node is not present in the request packet, the protected directory will be created with default settings ssl=true/false (depending on site settings), nonssl=true and cgi=false.
- The property node is required if the location node is
specified . It specifies the protected directory property. You
cannot disable all protected directory properties. At least one
value should be true after performing the add operation.
Data type: ProtectedDirLocationProperty (
protected_dir.xsd
). - The name node is required if the location node is specified . It specifies the protected directory property name. Data type: string.
- The value node is required if the location node is specified . It specifies the protected directory property value. Data type: boolean.
Note: When creating request packets, put nodes and elements in the order they follow in the packet structure.
Response Packet Structure
The add node of the output XML packet is presented by type
ProtectedDirAddOutput (protected_dir.xsd
) and 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: resultType (
common.xsd
). - The status node is required. It specifies the execution status of the operation. Data type: string. Allowed values: ok | error.
- The errcode node is optional. Is returns the error code if the operation fails. Data type: integer.
- The errtext node is optional. It returns the error message if the operation fails. Data type: string.
- The id node is required if the operation succeeds . It returns the ID of the added protected directory. Data type: integer.
Samples
The following request packet creates MyDirectory
protected directory
on the site with ID 1. The packet is valid only in Plesk for Linux/Unix.
<packet version="1.6.3.0">
<protected-dir>
<add>
<site-id>1</site-id>
<name>MyDirectory</name>
<header>This is a header!</header>
<location>
<property>
<name>ssl</name>
<value>true</value>
</property>
<property>
<name>nonssl</name>
<value>false</value>
</property>
<property>
<name>cgi</name>
<value>false</value>
</property>
</location>
</add>
</protected-dir>
</packet>
Response:
<packet version="1.6.3.0">
<protected-dir>
<add>
<result>
<status>ok</status>
<id>1</id>
</result>
</add>
</protected-dir>
</packet>
If site was not found, the response is as follows:
<packet version="1.6.3.0">
<protected-dir>
<add>
<result>
<status>error</status>
<errcode>1015</errcode>
<errtext>site is not found</errtext>
</result>
...
</add>
</protected-dir>
</packet>
If MyDirectory
directory already exists, the response is as follows:
<packet version="1.6.3.0">
<protected-dir>
<add>
<result>
<status>error</status>
<errcode>1007</errcode>
<errtext>URL with name 'name' already exists</errtext>
</result>
...
</add>
</protected-dir>
</packet>