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/1.6.7.0/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/1.6.7.0/agent_output.svg.

Alternatively, if you have a Plesk installation, you can obtain the schemas directly at:

  • (Linux ) /usr/local/psa/admin/htdocs/schemas/rpc.
  • (Windows) %plesk_dir%\htdocs/schemas\rpc

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.

Creating Packets

Follow this guideline to create packets from XSD.

  1. 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>
  1. Open the agent_input.xsd schema.

    File agent_input.xsd lists all supported operators

    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>
  1. 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_input.xsd and 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:

    agent_input.xsd

    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>
  1. 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:

    xsd-list 4

    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 comments on this page

Leave your feedback or question on this documentation topic below. For technical assistance, contact your hosting service provider or submit a request to Plesk support. Suggest new features for Plesk here. Discuss general questions on the Plesk forum. All offtopic comments will be removed.