<?xml version="1.0"?>
<!--
  Author:  Jeff Larkin
  $Id: restregistry.xsd,v 1.16 2005/04/22 18:34:57 larkin Exp $
  
  Description:
    This file declares the ReST registry/installation history.
  
-->
<xs:schema targetNamespace="http://icl.cs.utk.edu/ReST/Registry/1.0"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="http://icl.cs.utk.edu/ReST/Registry/1.0"
           xmlns:pack="http://icl.cs.utk.edu/ReST/Package/1.0">
  <xs:import namespace="http://icl.cs.utk.edu/ReST/Package/1.0"
          schemaLocation="http://icl.cs.utk.edu/rest/restpackage-1_0.xsd"/>
  <!-- Registry root element -->
  <xs:element name="registry">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="environment"/>
        <xs:element ref="locations"/>
        <xs:element ref="packageheaders"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <!-- Saves environment information such as key locations and known_hosts
       location to keep from having to locate these things every time an 
       application is run. -->
  <xs:element name="environment">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="keys" minOccurs="0"/>
        <xs:element ref="knownhosts" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <!-- A list of all servers that have been accessed via GSAP software -->
  <xs:element name="locations">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="location" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <!-- A list of package headers for all packages that have been installed
       somewhere via GSAP software.  -->
  <xs:element name="packageheaders">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="pack:header" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <!-- A list of keys used by the user -->
  <xs:element name="keys">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="key" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <!-- A key location -->
  <xs:element name="key" type="xs:string"/>
  
  <!-- The location of the known_hosts file -->
  <xs:element name="knownhosts" type="xs:string"/>
  
  <!-- The username on a specific server -->
  <xs:element name="user" type="xs:string"/>
  
  <!-- The location (hostname or IP) of a specific server -->
  <xs:element name="host" type="xs:string"/>  
  
  <!-- The port over which to communicate w/ a specific server -->
  <xs:element name="port" type="xs:int"/>
  
  <!-- The username on a specific server -->
  <xs:element name="name" type="xs:string"/>
  
  <!-- The version of a package installed on a server -->
  <xs:element name="version" type="xs:string"/>
  
  <!-- The group used in installing a package on a server -->
  <xs:element name="group">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <!-- Group type, probably logical or password -->
          <xs:attribute name="type" type="xs:string" use="required"/>
          <!-- Is this the master location for the group -->
          <xs:attribute name="filemaster" type="xs:boolean"/>
          <xs:attribute name="buildmaster" type="xs:boolean"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  
  <!-- Packages that have been installed on a specific server -->
  <xs:element name="packages">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="package" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <!-- Information about a specific package on a specific server -->
  <xs:element name="package">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="name"/>
        <xs:element ref="version"/>
        <!-- If no logical or password group is defined, the default groups 
             are assumed -->
        <xs:element ref="group" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="history"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <!-- Information about a known server -->
  <xs:element name="location">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="user"/>
        <xs:element ref="host"/>
        <xs:element ref="port"/>
        <xs:element ref="packages"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <!-- The history of what has been done to a package on a server (installed,
       updated, uninstalled, etc) -->
  <xs:element name="history">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="event" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <!-- When an event occurred -->
  <xs:element name="timestamp" type="xs:dateTime"/>
  <!-- Did the event succeed? -->
  <xs:element name="status" type="xs:string"/>
  <xs:element name="event">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="timestamp"/>
        <xs:element ref="status"/>
      </xs:sequence>
      <!-- What were we trying to do? -->
      <xs:attribute name="type" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
</xs:schema>
