<?xml version="1.0" encoding="UTF-8"?>
<grammar
    xmlns="http://relaxng.org/ns/structure/1.0"
    xmlns:a="http://www.example.com/annotation"
    ns="http://buildservice.org/api"
    datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

  <include href="obs.rng"/>

  <start>
    <ref name="jobstatus-element"/>
  </start>

  <define ns="" name="jobstatus-element">
    <element ns="" name="jobstatus">
      <a:documentation>
        This element stores the information of the currently active job.

        All attributes and elements are only present if a job is currently
        running, otherwise the reply is empty.
      </a:documentation>

      <optional>
        <interleave>

          <attribute name="code">
            <ref name="repository-code"/>
          </attribute>
          <optional>
            <attribute name="result">
              <ref name="jobstatus-result"/>
              <a:documentation>
               This attribute is present, if the package finished building. Then the
               status of the build result is available via it.
              </a:documentation>
            </attribute>
          </optional>

          <optional>
            <attribute name="details">
              <text/>
            </attribute>
          </optional>

          <element name="starttime">
            <a:documentation>
             The unix time at which the build started.
            </a:documentation>
            <data type="nonNegativeInteger"/>
          </element>

          <optional>
            <element name="endtime">
              <a:documentation>
               The unix time at which the build finished.
              </a:documentation>
              <data type="nonNegativeInteger"/>
            </element>
          </optional>

          <optional>
            <element name="lastduration">
              <a:documentation>
               Time in seconds that the last build took.
              </a:documentation>
              <data type="nonNegativeInteger"/>
            </element>
          </optional>

          <element name="workerid">
            <a:documentation>
             ID of the worker that is running this build
            </a:documentation>
            <text/>
          </element>

          <element name="hostarch">
            <a:documentation>
             Native architecture of the worker
            </a:documentation>
            <ref name="build-arch"/>
          </element>

          <optional>
            <element name="arch">
              <a:documentation>
               Architecture of the build
              </a:documentation>
              <ref name="build-arch"/>
            </element>
          </optional>

          <element name="uri">
            <a:documentation>
             internal URI to reachh the worker
            </a:documentation>
            <text/>
          </element>

          <element name="jobid">
            <a:documentation>
             internal md5 of this build job
            </a:documentation>
            <text/>
          </element>

          <optional>
            <element name="job">
              <a:documentation>
               internal name of this build job
              </a:documentation>
              <text/>
            </element>
          </optional>

          <optional>
            <element name="attempt">
              <a:documentation>
               number of attempts to build the job
              </a:documentation>
              <data type="nonNegativeInteger"/>
            </element>
          </optional>

        </interleave>
      </optional>

    </element>
  </define>
</grammar>
