Changing Protected Directory Properties

Use the set operation to change protected directory properties.

In this chapter:

Request Packet Structure

Response Packet Structure

Samples

 

Request Packet Structure

A request XML packet changing protected directory properties includes the set operation node:

<packet>
<protected-dir>
<set>
...  
</set>
</protected-dir>
</packet>

 

The set node is presented by type ProtectedDirAddInput (protected_dir.xsd), and its graphical representation is as follows:

  • The filter node is required. It specifies the filtering rule. For details, refer to the Available Filters section. Data type: ProtectedDirFilter (protected_dir.xsd).
  • The values node is required. It specifies the protected directory properties. The node is presented by type ProtectedDir (protected_dir.xsd). Its graphical representation is as follows:

    SetProtectedDirValuesRPS

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 name node is optional. 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. The location node can be specified only in Plesk for Linux/Unix. Data type: complex.
  • 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 set 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. Names and values of properties that can be changed for a specific site or common for all sites properties can be retrieved using the get-pd-location-descriptor operation.
  • The value node is required if the location node is specified. It specifies the protected directory property value. Data type: boolean.

Important: When creating request packets, put nodes and elements in the order they follow in the packet structure.

 

Response Packet Structure

The set node of the output XML packet is presented by type ProtectedDirSetOutput (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: resultFilterType (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. It 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 filter-id node is required if the request packet is valid. It returns the filtering rule parameter. For details, refer to the Available Filters section. Data type: anySimple.
  • The id node is required if the operation succeeds. It returns the ID of the protected directory which properties were changed. Data type: integer.
 

Samples

Changing properties of a single protected directory

The following packet changes properties of the protected directory with ID 1. The packet is valid only in Plesk for Linux/Unix.

<packet>
<protected-dir>
    <set>
       <filter>
          <id>1</id>
       </filter>
       <values>
         <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>
      </values>
    </set>
  </protected-dir>
</packet>

Response:

<packet>
<protected-dir>
      <set>
        <result>
          <status>ok</status>
          <filter-id>1</filter-id>
          <id>1</id>
        </result>
      </set>
    </protected-dir>
</packet>

 

If the directory was not found, the response from the server is as follows:

<packet>
<protected-dir>
  <set>
    <result>
     <status>error</status>
     <errcode>1013</errcode>
     <errtext>Protected URL is not found</errtext>
     <filter-id>1</filter-id>
    </result>
  </set>
</protected-dir>
</packet>

 

If invalid header text was specified in the request packet, the response from the server looks as follows:

<packet>
<protected-dir>
  <set>
    <result>
     <status>error</status>
     <errcode>1019</errcode>
     <errtext>Invalid value for 'header' specified</errtext>
     <filter-id>1</filter-id>
    </result>
  </set>
</protected-dir>
</packet> 
Changing properties of multiple protected directories

The following packet changes properties of all protected directories available for a packet sender. The packet is valid only in Plesk for Linux/Unix.

<packet>
<protected-dir>
    <set>
       <filter/>
       <values>
         <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>
       </values>
    </set>
  </protected-dir>
</packet>

Response:

<packet>
<protected-dir>
      <set>
        <result>
          <status>ok</status>
          <filter-id>1</filter-id>
          <id>1</id>
        </result>
        <result>
          <status>ok</status>
          <filter-id>2</filter-id>
          <id>2</id>
        </result>
      </set>
    </protected-dir>
</packet>

 

 

Leave your feedback on this topic here

If you have questions or need support, please visit the Plesk forum or contact your hosting provider.
The comments below are for feedback on the documentation only. No timely answers or help will be provided.