Creating Packets from XML Schemas
If you would like to, you can construct packets directly from XML schemas (XSD) eliminating the need in the reference part of this document. To get started, you need to obtain the XSD files and open them in your favorite browser (we will use Mozilla Firefox). After you are ready, analyze the XSD files that contain the operation you need and create the required packet.
Obtaining XSD Files
All XSD files which define the format of XML API packets are packed to the archive
schemas.zip. The archive contains a separate folder with a set of XML API schemas for each protocol version supported by Plesk.
An entry point to the XML schemas for the request packets is
agent_input.xsd. This file references all lower-level input schemas available. The interactive schema navigator is available here: http://plesk.github.io/api-schemas/22.214.171.124/agent_input.svg.
An entry point to the XML schemas for the response packets is
agent_output.xsd. This file references all lower-level output schemas available. The interactive schema navigator is available here: http://plesk.github.io/api-schemas/126.96.36.199/agent_output.svg.
Alternatively, if you have a Plesk installation, you can obtain the schemas directly at:
- (Linux )
The XSD files applicable to the current version of Plesk can be downloaded from the following section of this guide: XML Schemas for XML API Operators
Follow this guideline to create packets from XSD.
- Initially, you should have the following packet template which you will further extend with the details of an operation you want to commit.
<?xml version="1.0" encoding="UTF-8" ?> <packet> </packet>
- Open the
On the above figure, complex data type RequestPacketType lists all supported operator elements. These operators are: server, customer, webspace, and so on. Each operator has a matching request data type (the type attribute). This data type describes the structure of the operator. For example, you need the ip operator. Add the operator node to your packet (the name should match the value of the xs:element name argument). Please notice that the ip node is described by the IpInputType type.
<?xml version="1.0" encoding="UTF-8" ?> <packet> <ip> </ip> </packet>
- Open XML Schemas for XML API Operators and find the schemas that correspond explicitly to the operator of your choice. In case of the IP addresses management, we have two schemas:
ip_output.xsd. We should open the input schema to create a request packet and output for response packets. In case there is only a single XSD file, open it. After you open the operator's XSD, you will see the following structure:
As you remember, the ip node is described by the IpInputType. Actually, this type describes all available operations of the ip operator. You should find this type and extend the packet with the child node corresponding to a desired operation. For example, if we would like to change settings of a certain IP address, we add the set node to our packet.
<?xml version="1.0" encoding="UTF-8" ?> <packet> <ip> <set> </set> </ip> </packet>
- In turn, the set operation is described by a complex type that has a filter node that is followed by a choice between the type and certificate_name nodes:
Extend the packet with the provided structure:
<?xml version="1.0" encoding="UTF-8" ?> <packet> <ip> <set> <filter></filter> <type></type> </set> </ip> </packet>
All nested elements of filter and type nodes are also described by specific data types. Continue by applying the same approach to all the subsequent data, and in the end you will have the packet you need.
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.