<?xml version="1.0" encoding="UTF-8"?>

<xs:schema targetNamespace="http://xmlns.krupczak.org/xsd/xmpdconfigs-1.0"
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:smi="http://xmlns.krupczak.org/xsd/xmptypes-2.1"
   xmlns:xmp="http://xmlns.krupczak.org/xsd/xmp-1.0"
   xmlns:conf="http://xmlns.krupczak.org/xsd/xmpdconfigs-1.0"
   elementFormDefault="qualified" attributeFormDefault="unqualified">

 <xs:annotation>
   <xs:documentation>
    XML Schema for XMP agent configuration files:
       xmpd.xml
       cartographer.xml
       cartographer-local.xml
       appdata.xml
       connectiondata.xml
    Version $Id$
    Last update Fri Oct 26 16:28:11 EDT 2012
   </xs:documentation>
 </xs:annotation>

<xs:import namespace="http://xmlns.krupczak.org/xsd/xmptypes-2.1" 
        schemaLocation="http://xmlns.krupczak.org/xsd/xmptypes-2.1.xsd"/>

<!-- xmpd.xml definitions ===================================== -->

<xs:simpleType name="onOffNumeralType">
  <xs:restriction base="xs:integer">
   <xs:enumeration value="0"/>
   <xs:enumeration value="1"/>
  </xs:restriction>
</xs:simpleType>

<xs:simpleType name="protocolOperations">
   <xs:restriction base="xs:string">
      <xs:enumeration value="response"/>
      <xs:enumeration value="getrequest"/>
      <xs:enumeration value="setrequest"/>
      <xs:enumeration value="selecttablerequest"/>
      <xs:enumeration value="inserttablerequest"/>
      <xs:enumeration value="deletetablerequest"/>
      <xs:enumeration value="updatetablerequest"/>
      <xs:enumeration value="trap"/>
      <xs:enumeration value="information"/>
      <xs:enumeration value="all"/>
      <xs:enumeration value="Response"/>
      <xs:enumeration value="GetRequest"/>
      <xs:enumeration value="SetRequest"/>
      <xs:enumeration value="SelectTableRequest"/>
      <xs:enumeration value="InsertTableRequest"/>
      <xs:enumeration value="DeleteTableRequest"/>
      <xs:enumeration value="UpdateTableRequest"/>
      <xs:enumeration value="Trap"/>
      <xs:enumeration value="Information"/>
      <xs:enumeration value="All"/>
   </xs:restriction>
</xs:simpleType>

<xs:simpleType name="protocolOperationsList">
  <xs:list itemType="conf:protocolOperations"/>
</xs:simpleType>

<xs:complexType name="authenUserType">
 <xs:sequence>
   <xs:element name="user" type="xs:string">
    <xs:annotation>
      <xs:documentation>
      A string name to associate with this XMP user (e.g. changeit)
      </xs:documentation>
    </xs:annotation>
   </xs:element>
   <xs:element name="protocol_ops" type="conf:protocolOperationsList">
    <xs:annotation>
      <xs:documentation>
      A comma-separated list of XMP protocol PDUs or message types.
      </xs:documentation>
     </xs:annotation>
    </xs:element>
   <xs:element name="mibs" type="xs:string">
    <xs:annotation>
      <xs:documentation>
      A comma or space-separated list of MIBs that the protocol operations 
      are applied to.
      </xs:documentation>
     </xs:annotation>
   </xs:element>
 </xs:sequence>
</xs:complexType>

<xs:element name="xmpd_config">
  <xs:annotation>
    <xs:documentation>
    Main configuration file for the xmp agent engine.  Version
    of this config is included as an attribute of the element tag.
    </xs:documentation>
  </xs:annotation>

  <xs:complexType>
    <xs:choice minOccurs="1" maxOccurs="unbounded">
     <xs:element name="xmpd_trace" type="conf:onOffNumeralType"/>
     <xs:element name="xmpd_verbose" type="conf:onOffNumeralType"/>
     <xs:element name="xmpd_port" type="xs:integer"/>
     <xs:element name="xmpd_daemon" type="conf:onOffNumeralType"/>
     <xs:element name="xmpd_eventageoutinterval" type="xs:integer"/>
     <xs:element name="xmpd_defaultmanager" type="xs:string"/>
     <xs:element name="xmpd_autoupgrade" type="xs:boolean"/>
     <xs:element name="xmpd_authenuser" type="conf:authenUserType"/>
    </xs:choice>
    <xs:attribute name="version" type="xs:integer" use="required"/>
  </xs:complexType>
</xs:element>

<!-- cartographer.xml definitions ============================== -->

<xs:element name="cartographerConfig">

  <xs:annotation>
    <xs:documentation>
    Main configuration file for the Cartographer plugin.   Version of this
    config is included as an attribute of the element tag.
    </xs:documentation>
  </xs:annotation>

  <xs:complexType>
    <xs:choice minOccurs="1" maxOccurs="unbounded">
      <xs:element name="dependencyAgeOutInterval" type="xs:integer"/>
      <xs:element name="peerAgeOutInterval" type="xs:integer"/>
      <xs:element name="xmpAuthenUser" type="xs:string"/>
      <xs:element name="dependencyScanInterval" type="xs:string"/>
    </xs:choice>
    <xs:attribute name="version" type="xs:integer" use="required"/>
  </xs:complexType>

</xs:element>

<!-- cartographer-local.xml definitions ======================= -->

<xs:complexType name="dependencyDeclarationType">
  <xs:sequence>
     <xs:element name="dependClient" type="xs:string"/>
     <xs:element name="dependServer" type="xs:string"/>
     <xs:element name="dependType" type="smi:dependencyStringType"/>
     <xs:element name="dependArgs" type="xs:string"/>
     <xs:element name="dependReference" type="smi:dependencyReferenceStringType"/>
     <xs:choice minOccurs="0" maxOccurs="unbounded">
       <xs:element name="ipVersion" type="xs:integer"/>
     </xs:choice>
  </xs:sequence>
</xs:complexType>

<xs:complexType name="logfileDependencyDeclarationType">
  <xs:sequence>
    <xs:element name="logfile" type="xs:string"/>
    <xs:element name="dependType" type="smi:dependencyStringType"/>
    <xs:element name="addExpression" type="xs:string"/>
    <xs:element name="removeExpression" type="xs:string"/>
    <xs:element name="dependClient" type="xs:string"/>
    <xs:element name="dependServer" type="xs:string"/>
    <xs:element name="dependArgs" type="xs:string"/>
    <xs:element name="scanInterval" type="xs:integer"/>
    <xs:element name="timeout" type="xs:integer"/>
     <xs:choice minOccurs="0" maxOccurs="unbounded">
       <xs:element name="description" type="xs:string"/>
     </xs:choice>
  </xs:sequence>
</xs:complexType>

<xs:complexType name="logfileMonitorDeclarationType">
  <xs:sequence>
    <xs:element name="logfile" type="xs:string"/>
    <xs:element name="expression" type="xs:string"/>
    <xs:element name="scanInterval" type="xs:integer"/>
     <xs:choice minOccurs="0" maxOccurs="unbounded">
       <xs:element name="description" type="xs:string"/>
     </xs:choice>
  </xs:sequence>
</xs:complexType>

<xs:complexType name="systemConfigType">
  <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element name="dependency" type="conf:dependencyDeclarationType"/>
    <xs:element name="logfileDependency" type="conf:logfileDependencyDeclarationType"/>
    <xs:element name="logfileMonitor" type="conf:logfileMonitorDeclarationType"/>
  </xs:choice>
  <xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>

<xs:element name="cartographerLocal">
  <xs:annotation>
    <xs:documentation>
    Local system-specific configuration file for the Cartographer plugin.
    Version of this config is included as an attribute of the element tag.
    cartographer-local.xml is distributed and updated by the agent engine
    and can contain multiple system declarations, each targeted to a 
    separate system.
    </xs:documentation>
  </xs:annotation>

  <xs:complexType>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element name="system" type="conf:systemConfigType"/>
    </xs:choice>
    <xs:attribute name="version" type="xs:integer" use="required"/>
  </xs:complexType>

</xs:element>

<!-- appdata.xml definitions ===================================== -->

<xs:complexType name="appDeclarationType">
  <xs:sequence>
     <xs:element name="appname" type="xs:string"/>
     <xs:element name="appfilter" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

<xs:element name="applicationData">
  <xs:annotation>
   <xs:documentation>
    This configuration file, appdata.xml, is tracked and distributed
    by the agent engine.  A version number is included as an attribute of
    the element tag.  The config file consists of statements that define
    applications by processes that they contain.
   </xs:documentation>
  </xs:annotation>

  <xs:complexType>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element name="application" type="conf:appDeclarationType"/>
    </xs:choice>
    <xs:attribute name="version" type="xs:integer" use="required"/>
  </xs:complexType>
</xs:element>

<!-- connectiondata.xml definitions =============================== -->

<xs:simpleType name="portNumberType">
  <xs:restriction base="xs:unsignedShort">
    <xs:minInclusive value="1"/>
  </xs:restriction>
</xs:simpleType>

<xs:simpleType name="protoStringType">
  <xs:restriction base="xs:string">
    <xs:enumeration value="tcp"/>
    <xs:enumeration value="udp"/>
  </xs:restriction>
</xs:simpleType>

<xs:complexType name="connectionDeclarationType">
  <xs:sequence>
    <xs:element name="proto" type="conf:protoStringType"/>
    <xs:element name="port" type="conf:portNumberType"/>
    <xs:element name="dependencyType" type="smi:dependencyTypeType"/>
    <xs:element name="args" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

<xs:element name="connectionData">
  <xs:annotation>
   <xs:documentation>
    This configuration file, connectiondata.xml, is tracked and distributed
    by the agent engine.  A version number is included as an attribute of
    the element tag.  The config file consists of statements that 
    map UDP and TCP connections/ports to dependency types.
   </xs:documentation>
  </xs:annotation>

  <xs:complexType>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element name="connection" type="conf:connectionDeclarationType"/>
    </xs:choice>
    <xs:attribute name="version" type="xs:integer" use="required"/>
  </xs:complexType>
</xs:element>

</xs:schema>
