If the traffic usage is calculated on a subscription by statistics facilities of Plesk, this data is added to Plesk automatically. If this data is gathered using some external statistics means, the set_traffic operation can help add this data to Plesk database.

Request Packet Structure

A request XML packet that sets traffic data for a certain subscription should include the set_traffic operation node:

<packet>
<webspace>
   <set_traffic>
   ...
   </set_traffic>
</webspace>
</packet>

The set_traffic node does not have a separate type, it is nested within the complex type (domain_input.xsd). The set_traffic node has the following graphics representation:

image 33938

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 dom_id node is required. It identifies the subscription whose traffic settings are set. Data type: integer.
  • The date node is required. It specifies the date for which the traffic data is set. Data type: date. Format: YYYY-MM-DD.
  • The smtp_in node is required. It specifies the incoming traffic (in bytes) got via SMTP protocol. Data type: integer.
  • The smtp_out node is required. It is used to show the outgoing SMTP traffic (in bytes). Data type: integer.
  • The pop3_imap_in node is required. It specifies the incoming traffic (in bytes) got via POP3 and IMAP protocols. Data type: integer.
  • The pop3_imap_out node is required. It is used to show the outgoing POP3/IMAP traffic (in bytes). Data type: integer.

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

Response Packet Structure

The set_traffic node of the response packet is structured as follows:

image 33941

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 optional. It wraps the result of the requested set_traffic operation. It can be missing if some error occurs before the validation starts. Data type: resultType (common.xsd).
  • The status node is required. It returns the execution status of the set_traffic operation. Data type: string. Allowed values: ok | error.
  • The errcode node is optional. Is used to return an error code when the set_traffic operation fails. Data type: unsignedInt.
  • The errtext node is optional. Can be used to return an error message if the set_traffic operation fails. Data type: string.
  • The id node is optional. Returns the identifier of the subscription whose traffic is set. It is missing if the request packet fails before the validation on the server side. Data type: integer.

Samples

To set traffic information for the specified subscription, use the following packet:

<packet version="1.6.3.0">
<webspace>
<set_traffic>
   <dom_id>1234</dom_id>
   <date>2005-12-12</date>
   <smtp_in>514237124628</smtp_in>
   <smtp_out>6153462547</smtp_out>
   <pop3_imap_in>49769379</pop3_imap_in>
   <pop3_imap_out>7236487263</pop3_imap_out>
</set_traffic>
</webspace>
</packet>

Response:

<packet version="1.6.3.0">
<webspace>
<set_traffic>
   <result>
      <status>ok</status>
      <id>1234</id>
   </result>
</set_traffic>
</webspace>
</packet>

To set traffic information for multiple subscriptions in one packet, use multiple <set_traffic> nodes:

<packet version="1.6.3.0">
<webspace>
<set_traffic>
   <dom_id>1134</dom_id>
   <date>2005-12-12</date>
   <smtp_in>127417</smtp_in>
   <smtp_out>342899</smtp_out>
   <pop3_imap_in>384769</pop3_imap_in>
   <pop3_imap_out>37947</pop3_imap_out>
</set_traffic>
<set_traffic>
   <dom_id>1135</dom_id>
   <date>2005-12-12</date>
   <smtp_in/>
   <smtp_out/>
   <pop3_imap_in>7835683295457</pop3_imap_in>
   <pop3_imap_out>32876583765</pop3_imap_out>
</set_traffic>
</webspace>
</packet>