<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns="http://www.swsoft.com/webservices/vza/3.0.3/protocol" xmlns:vzat="http://www.swsoft.com/webservices/vza/3.0.3/types" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.swsoft.com/webservices/vza/3.0.3/protocol" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:import schemaLocation="VZACommonTypes.xsd" namespace="http://www.swsoft.com/webservices/vza/3.0.3/types" />
  <xs:element name="packet">
    <xs:annotation>
      <xs:documentation>The root element of any Message. Everything starts here.</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent mixed="false">
        <xs:extension base="packet_headerType">
          <xs:sequence minOccurs="0">
            <xs:element name="data" type="dataType">
              <xs:annotation>
                <xs:documentation>The body of a Message itself. Can contain several classes of information directed to different Operators by specifying several "target"s.</xs:documentation>
              </xs:annotation>
            </xs:element>
          </xs:sequence>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  <xs:element name="packet_header" type="packet_headerType">
    <xs:annotation>
      <xs:documentation>Packet header</xs:documentation>
    </xs:annotation>
  </xs:element>
  <xs:element name="operator" type="operatorType">
    <xs:annotation>
      <xs:documentation>Operator is a part of VZAgent functionality, which  serves a set of related requests grouped by some common principle like User-Group Management operations. Usually, it should be deived by instanced Operator and there should be realized here two sequences or choices of elements: one for "input" requests and one for "output" responces.</xs:documentation>
    </xs:annotation>
  </xs:element>
  <xs:element name="operator_periodic" substitutionGroup="operator" type="operator_periodicType">
    <xs:annotation>
      <xs:documentation>Operator, which serves as a statistics collector and provides information on a periodic basis.</xs:documentation>
    </xs:annotation>
  </xs:element>
  <xs:element name="operator_functional" substitutionGroup="operator" type="operator_functionalType">
    <xs:annotation>
      <xs:documentation>Operator, allowing OK and Error in its body.</xs:documentation>
    </xs:annotation>
  </xs:element>
  <xs:complexType name="packet_headerType">
    <xs:annotation>
      <xs:documentation>Packet header type</xs:documentation>
    </xs:annotation>
    <xs:sequence minOccurs="0">
      <xs:element minOccurs="0" name="auth" type="authType">
        <xs:annotation>
          <xs:documentation>***INTERNAL*** Authorization information. For now it contains only veid of VE, permitted to access. For  superuser with login vzagent0 veid is omitted and he has full access.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" name="cookie" type="xs:string">
        <xs:annotation>
          <xs:documentation>User-defined information, used to hold some data, describing the packet. User will receive it back unchanged  in response from VZAgent.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="target" type="xs:string">
        <xs:annotation>
          <xs:documentation>Target, specifying name of an Operator to process a request, class of subscription or name of a Client in a response to him. When target is absent it's considered to be a system message ( see "system" in group "on_demands" ).</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" name="origin" type="xs:string">
        <xs:annotation>
          <xs:documentation>Message sender's name. It can be Operator's name or Client's name, generated by VZAgent, when the Client logged in.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" name="src" type="routeType">
        <xs:annotation>
          <xs:documentation>Source routing information. This is filled in with a corresponding Directors on a route out of the Operator, sending the request. Also, it is being duplicated into "dst" when reply is generated.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" name="dst" type="routeType">
        <xs:annotation>
          <xs:documentation>Destination routing information. This is set by the Operator, sending the remote request.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" name="session" type="xs:string">
        <xs:annotation>
          <xs:documentation>Session ID, used for SOAP connections and SOAP user authentication. The string contains name of the user and session ID separated by a dot.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="version" type="version_type">
      <xs:annotation>
        <xs:documentation>Version of VZAgent protocol. Since the first release, where version 0.5 of the protocol was used for Virtuozzo 2.0.2, version of Virtuozzo is used. Current implementation is 2.5.0. </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="id" type="xs:string" use="optional">
      <xs:annotation>
        <xs:documentation>ID of the packet. Used to identify the packet and its response, which will contain the same ID. Usually integer, but can be a string.
 The field is necessary to set if you need to see progress of your request processing and be notified in case of failure because of timeout or some other reason. Normal error message will be reported even for packets without ID.
ID should be unique per connection.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="priority" type="xs:string" use="optional">
      <xs:annotation>
        <xs:documentation>Priority of the packet. Used to specify the importance of it, when it's placed into a message queue or when some packet should be dropped in case of queue overflow. The higher priority value the less important is the packet. Zero is the default priority.
 
Priorities range from -3000 to 3000. 
-3000 to -1000 for heavy messages.
-999 to 999 for normal messages.
1000 to 3000 for urgent messages.
</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="time" type="vzat:datetime_type" use="optional">
      <xs:annotation>
        <xs:documentation>Time, when the packet was sent by it's creator.
</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute default="off" name="progress" use="optional">
      <xs:annotation>
        <xs:documentation>When present the automatic progress reporting is invoked for this request being processed.
</xs:documentation>
      </xs:annotation>
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="on" />
          <xs:enumeration value="off" />
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute default="off" name="log" use="optional">
      <xs:annotation>
        <xs:documentation>When present the automatic progress reporting is logged for the operations supporting it, so-called “logged operations”. Possible values are “on” or “off”. Default is “off”.</xs:documentation>
      </xs:annotation>
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="on" />
          <xs:enumeration value="off" />
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="type" type="xs:int" use="optional">
      <xs:annotation>
        <xs:documentation>*** INTERNAL ***
Bitfield for the internal type of the Message.
#define UNFINISHED 0x00000001
#define RESPONSE 0x00000002
#define RESCHEDULE 0x00000004
#define TIMEOUT 0x00000008
</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="timeout" type="xs:int" use="optional">
      <xs:annotation>
        <xs:documentation>*** INTERNAL ***
Timeout, which will be used for handling of this request. Might be specified in incoming packet or might be sent back from Operator, notifying its Director about the time he is going to handle it.
</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="timeout_limit" type="xs:int" use="optional">
      <xs:annotation>
        <xs:documentation>*** INTERNAL ***
Timeout limit for message processing. Used by an operator in determining the validity of it's timeout.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="uid" type="xs:int" use="optional">
      <xs:annotation>
        <xs:documentation>*** INTERNAL ***
UID of the user, which sent this packet.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
  <xs:complexType name="operatorType">
    <xs:annotation>
      <xs:documentation>Basic Operator type. Declares some Input commands, some Output responses and its Configuration if present. Should be inherited and reworked for specific Operators declaration.</xs:documentation>
    </xs:annotation>
  </xs:complexType>
  <xs:complexType name="operator_functionalType">
    <xs:annotation>
      <xs:documentation>Basic Operator type. Declares some Input commands, some Output responses and its Configuration if present. Should be inherited and reworked for specific Operators declaration.</xs:documentation>
    </xs:annotation>
    <xs:complexContent mixed="false">
      <xs:extension base="operatorType">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="ok">
            <xs:annotation>
              <xs:documentation>Ok is used when no other valid data is requested to send and the request was successfully completed.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="error">
            <xs:annotation>
              <xs:documentation>Error is used in any case when function call was not successful. Depending on an operator behaviour, message can stop further function calls  parsing or continue.</xs:documentation>
            </xs:annotation>
            <xs:complexType>
              <xs:sequence>
                <xs:element name="code" type="xs:int">
                  <xs:annotation>
                    <xs:documentation>Error code.</xs:documentation>
                  </xs:annotation>
                </xs:element>
                <xs:element minOccurs="0" name="message" type="xs:string">
                  <xs:annotation>
                    <xs:documentation>Error Message</xs:documentation>
                  </xs:annotation>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="operator_periodicType">
    <xs:annotation>
      <xs:documentation>Basic Periodic Operator type. Derived from operatorType it adds some common Input, allowing to configure periods of statistics processing.</xs:documentation>
    </xs:annotation>
    <xs:complexContent mixed="false">
      <xs:extension base="operator_functionalType">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:choice>
            <xs:annotation>
              <xs:documentation>Input</xs:documentation>
            </xs:annotation>
            <xs:element minOccurs="0" name="set_period" type="set_periodType">
              <xs:annotation>
                <xs:documentation>***INTERNAL*** Sets periods of collecting, logging and reporting information for logs ( in seconds ). Used by DBM operator only. Might not be implemented and used for strictly monitoring Periodic Operators.</xs:documentation>
              </xs:annotation>
            </xs:element>
            <xs:element minOccurs="0" name="report">
              <xs:annotation>
                <xs:documentation>***INTERNAL*** Request to send all of the collected data right away, instead of waiting for the "report" period to end. Used by DBM operator only.  Might not be implemented and used for strictly monitoring Periodic Operators.</xs:documentation>
              </xs:annotation>
            </xs:element>
            <xs:element name="start_monitor" type="start_monitorType">
              <xs:annotation>
                <xs:documentation>Starts another monitoring facility. Messages will be sent to the requesting client with "period" intervals. Target should be the name of the client requested monitoring.</xs:documentation>
              </xs:annotation>
            </xs:element>
            <xs:element name="stop_monitor" type="stop_monitorType">
              <xs:annotation>
                <xs:documentation>Stops the monitoring facility, started previously by the same client.</xs:documentation>
              </xs:annotation>
            </xs:element>
          </xs:choice>
          <xs:element maxOccurs="unbounded" name="configuration" type="periodic_configurationType">
            <xs:annotation>
              <xs:documentation>Common configuration of Periodic collectors. Can be present in both input and output packets.</xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:choice>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="set_periodType">
    <xs:annotation>
      <xs:documentation>Periodic Operators type, used for logging setup.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="collect" type="xs:int">
        <xs:annotation>
          <xs:documentation>Period with which a new data is collected and processed for staticstics. </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="log" type="xs:int">
        <xs:annotation>
          <xs:documentation>Period with which the collected data is summarized and added to a report, preparing for sending.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="report" type="xs:int">
        <xs:annotation>
          <xs:documentation>Period with which the compiled by log period message is sent to DBM.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="start_monitorType">
    <xs:sequence>
      <xs:element name="period" type="xs:int">
        <xs:annotation>
          <xs:documentation>Reporting period.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" name="veid" type="vzat:veid_type">
        <xs:annotation>
          <xs:documentation>VE ID (only for VE-related periodic operators).</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="stop_monitorType">
    <xs:sequence minOccurs="0">
      <xs:element minOccurs="0" name="veid" type="vzat:veid_type">
        <xs:annotation>
          <xs:documentation>VE ID (only for VE-related periodic operators).</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="authType">
    <xs:annotation>
      <xs:documentation>***INTERNAL*** Authorization information. For now it contains only veid of VE, permitted to access. For  superuser with login vzagent0 veid is omitted and he has full access.</xs:documentation>
    </xs:annotation>
    <xs:choice>
      <xs:annotation>
        <xs:documentation>Either of</xs:documentation>
      </xs:annotation>
      <xs:element minOccurs="0" name="ve_list" type="vzat:ve_listType">
        <xs:annotation>
          <xs:documentation>VE list</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="veid" type="vzat:veid_type">
        <xs:annotation>
          <xs:documentation>VE ID</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:choice>
  </xs:complexType>
  <xs:complexType name="event_configurationType">
    <xs:annotation>
      <xs:documentation>Event configuration structure</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="priority" type="xs:int">
        <xs:annotation>
          <xs:documentation>Priority of the Event Messages.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="period" type="xs:int">
        <xs:annotation>
          <xs:documentation>Period of checking.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="periodic_configurationType">
    <xs:sequence>
      <xs:element name="log_priority" type="xs:int">
        <xs:annotation>
          <xs:documentation>Priority of  log packets.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="monitor_priority" type="xs:int">
        <xs:annotation>
          <xs:documentation>Priority of monitor packets.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="min_monitor_period" type="xs:int">
        <xs:annotation>
          <xs:documentation>Minimum monitoring period available for a USER client.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="min_monitor_period_root" type="xs:int">
        <xs:annotation>
          <xs:documentation>Minimum monitoring period available for a ROOT client.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="routeType">
    <xs:sequence>
      <xs:element minOccurs="0" name="director" type="xs:string">
        <xs:annotation>
          <xs:documentation>The Director, Operator belongs to.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" name="host" type="xs:string">
        <xs:annotation>
          <xs:documentation>VZAgent ID of the host, by which the host address will be taken. Should be either contained in VZAgent configuration (global mapping) or be a result of exclusive connect.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" name="index" type="xs:string">
        <xs:annotation>
          <xs:documentation>For on-demands and other multiple accessors it specifies the particular target.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" name="target" type="xs:string">
        <xs:annotation>
          <xs:documentation>Real origin is saved here, when packet is sent remotely.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="dataType">
    <xs:choice maxOccurs="unbounded">
      <xs:element ref="operator" />
      <xs:group ref="file_transfer" />
    </xs:choice>
  </xs:complexType>
  <xs:group name="file_transfer">
    <xs:annotation>
      <xs:documentation>File Transfer. Target tag should contain file_transfer.</xs:documentation>
    </xs:annotation>
    <xs:choice>
      <xs:choice>
        <xs:annotation>
          <xs:documentation>Input</xs:documentation>
        </xs:annotation>
        <xs:element name="read_block">
          <xs:annotation>
            <xs:documentation>Reads a block from file. Returns "read" or Error. The block itself is sent right after the binary zero, delimiting the response and contain exactly the "size" of bytes, specified in response.</xs:documentation>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:element name="path" type="xs:string">
                <xs:annotation>
                  <xs:documentation>Path to file in uploads directory.</xs:documentation>
                </xs:annotation>
              </xs:element>
              <xs:element name="offset" type="xs:long">
                <xs:annotation>
                  <xs:documentation>Offset in file.</xs:documentation>
                </xs:annotation>
              </xs:element>
              <xs:element name="size" type="xs:long">
                <xs:annotation>
                  <xs:documentation>Size of the block.</xs:documentation>
                </xs:annotation>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="write_block">
          <xs:annotation>
            <xs:documentation>Writes a block to file. Returns "write" or Error. The block itself should be sent right after this message and contain exactly the "size" of bytes, specified in the parameters. </xs:documentation>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:element name="path" type="xs:string">
                <xs:annotation>
                  <xs:documentation>Path to file in uploads directory.</xs:documentation>
                </xs:annotation>
              </xs:element>
              <xs:element name="offset" type="xs:long">
                <xs:annotation>
                  <xs:documentation>Offset in file.</xs:documentation>
                </xs:annotation>
              </xs:element>
              <xs:element name="size" type="xs:long">
                <xs:annotation>
                  <xs:documentation>Size of the block.</xs:documentation>
                </xs:annotation>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="get_size">
          <xs:annotation>
            <xs:documentation>Gets size of the file. Returns "size" or Error</xs:documentation>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:element name="path" type="xs:string">
                <xs:annotation>
                  <xs:documentation>Path to file in uploads directory.</xs:documentation>
                </xs:annotation>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="create_socket">
          <xs:annotation>
            <xs:documentation>Create a special local socket in client directory. This socket is used by exec in special mode. </xs:documentation>
          </xs:annotation>
        </xs:element>
      </xs:choice>
      <xs:choice>
        <xs:annotation>
          <xs:documentation>Output</xs:documentation>
        </xs:annotation>
        <xs:element name="read">
          <xs:annotation>
            <xs:documentation>Size of bytes read.</xs:documentation>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:element name="size" type="xs:long" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="write">
          <xs:annotation>
            <xs:documentation>Size of bytes written.</xs:documentation>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:element name="size" type="xs:long" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="size" type="xs:long">
          <xs:annotation>
            <xs:documentation>Size of file.</xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element name="switch_to_raw">
          <xs:annotation>
            <xs:documentation>Signals switching to raw mode.</xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element name="switch_to_vza">
          <xs:annotation>
            <xs:documentation>Signals switching back to vza mode.</xs:documentation>
          </xs:annotation>
        </xs:element>
      </xs:choice>
    </xs:choice>
  </xs:group>
  <xs:simpleType name="version_type">
    <xs:annotation>
      <xs:documentation>Packet version string.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="\d{1,2}\.\d{1,2}\.\d{1,2}" />
      <xs:pattern value="\d{1,2}\.\d{1,2}" />
    </xs:restriction>
  </xs:simpleType>
</xs:schema>