<!--
		SIF Infrastructure Specification 3.7

		(January 21, 2025)
		
		Infrastructure Version: 3.7
		
		license: 
		    name: Apache  2.0
        identifier: Apache-2.0
        url: 'https://home.a4l.org/legal/'
	-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sifassociation.org/infrastructure/3.7" targetNamespace="http://www.sifassociation.org/infrastructure/3.7" elementFormDefault="qualified" version="3.7">
  <xs:complexType name="jobType">
    <xs:annotation>
      <xs:appinfo>
        <sifChar />
        <privacyRating />
      </xs:appinfo>
      <xs:documentation>All functional services must use this object design to track state. While Events may be published back to the objects creator, they must not be published to the Consumer when the event was generated based on its request (since results were included in the response). Each functional service should define the expectations of how management of the job is managed for both the Consumer and Provider. For instance, certain optional fields may need to be included in-order-to successfully cause a job to be created.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="name" type="xs:token">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>M</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation>The name of the job, e.g. "grading" or "sre".</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="description" minOccurs="0" type="xs:string">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>O</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation>A description of the job, e.g. "Bowers Elementary School Final Marks"</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="state" minOccurs="0" type="jobStateType">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>O</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation>The current enumerable state of the job.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="stateDescription" minOccurs="0" type="xs:string">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>O</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation>A descriptive message elaborating on the current state, e.g. if the current state is "FAILED" the stateDescription may be "Timeout occured".</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="created" minOccurs="0" type="xs:dateTime">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>O</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation>The datetime this job was created.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="lastModified" minOccurs="0" type="xs:dateTime">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>O</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation>The datetime this job was last modified.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="timeout" minOccurs="0" type="xs:duration">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>O</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation>The ammount of time after creation before this job is automatically deleted.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="phases" minOccurs="0" type="phaseCollectionType">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>O</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation>The phases that make up this job.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="initialization" minOccurs="0" type="initializationType">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>O</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation />
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="id" use="optional" type="uuidType">
      <xs:annotation>
        <xs:appinfo>
          <sifChar>O</sifChar>
          <privacyRating />
        </xs:appinfo>
        <xs:documentation />
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:element name="job" type="jobType">
    <xs:key name="jobKey1">
      <xs:selector xpath="." />
      <xs:field xpath="@id" />
    </xs:key>
  </xs:element>

  <xs:complexType name="jobCollectionType">
    <xs:sequence>
      <xs:element name="job" type="jobType" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="jobs" type="jobCollectionType" />

</xs:schema>