<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../xslt/schema.xsl"?>

<!-- (C) 2011 OpenStack Foundation., All Rights Reserved -->

<schema
    elementFormDefault="qualified"
    attributeFormDefault="unqualified"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:csapi="http://docs.openstack.org/compute/api/v1.1"
    xmlns:xsdxt="http://docs.rackspacecloud.com/xsd-ext/v1.0"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
    targetNamespace="http://docs.openstack.org/compute/api/v1.1"
>
  <annotation>
    <xsd:appinfo
        xml:lang="EN"
        xmlns="http://www.w3.org/1999/xhtml">
      <xsdxt:title>Images</xsdxt:title>
      <xsdxt:link rel="index" href="api.xsd" />
    </xsd:appinfo>
    <xsd:documentation
        xml:lang="EN"
        xmlns="http://www.w3.org/1999/xhtml">
      <p>
        This schema file defines all entity related to <a
        href="#type_Image" title="See definition of Image">Images</a>.
      </p>
    </xsd:documentation>
  </annotation>

  <!-- Import ATOM specific schema definitions -->
  <import namespace="http://www.w3.org/2005/Atom" schemaLocation="atom/atom.xsd" />

  <include schemaLocation="common.xsd">
    <annotation>
      <xsd:documentation
          xml:lang="EN"
          xmlns="http://www.w3.org/1999/xhtml">
        <p>
          Common types used by multiple entities and possibly spanning
          several types of requests.
        </p>
      </xsd:documentation>
    </annotation>
  </include>
  <include schemaLocation="server.xsd">
    <annotation>
      <xsd:documentation
          xml:lang="EN"
          xmlns="http://www.w3.org/1999/xhtml">
        <p>
          Servers and all internal Entities including: Addresses,
          and Files.
        </p>
      </xsd:documentation>
    </annotation>
  </include>
  <include schemaLocation="faults.xsd">
    <annotation>
      <xsd:documentation
          xml:lang="EN"
          xmlns="http://www.w3.org/1999/xhtml">
        <p>
          All fault types.
        </p>
      </xsd:documentation>
    </annotation>
  </include>

  <element name="image" type="csapi:Image">
    <annotation>
      <xsd:documentation
          xml:lang="EN"
          xmlns="http://www.w3.org/1999/xhtml">
        <p>
          The element defines a collection of files used to create or
          rebuild a server.
        </p>
      </xsd:documentation>
      <xsd:appinfo>
        <xsdxt:samples>
          <xsdxt:sample>
            <xsdxt:code type="application/xml" href="../samples/image.xml" />
          </xsdxt:sample>
          <xsdxt:sample>
            <xsdxt:code type="application/json" href="../samples/image.json" />
          </xsdxt:sample>
        </xsdxt:samples>
      </xsd:appinfo>
    </annotation>
  </element>
  <element name="images" type="csapi:Images">
    <annotation>
      <xsd:documentation
          xml:lang="EN"
          xmlns="http://www.w3.org/1999/xhtml">
        <p>
          A collection of images.
        </p>
      </xsd:documentation>
      <xsd:appinfo>
        <xsdxt:samples>
          <xsdxt:sample>
            <xsdxt:code type="application/xml" href="../samples/images.xml" />
          </xsdxt:sample>
          <xsdxt:sample>
            <xsdxt:code type="application/json" href="../samples/images.json" />
          </xsdxt:sample>
        </xsdxt:samples>
      </xsd:appinfo>
    </annotation>
  </element>

  <!-- Complex Types -->
  <complexType name="Image">
    <sequence>
        <element name="server" type="csapi:Server" minOccurs="0">
            <annotation>
                <xsd:documentation
                    xml:lang="EN"
                    xmlns="http://www.w3.org/1999/xhtml">
                    <p>
                        The server associated with the image. This may
                        not contain full server details but will
                        always contain an ID, a name, as well as self
                        and bookmark links.
                    </p>
                </xsd:documentation>
            </annotation>
        </element>
        <element name="metadata" type="csapi:Metadata" minOccurs="0">
            <annotation>
                <xsd:documentation
                    xml:lang="EN"
                    xmlns="http://www.w3.org/1999/xhtml">
                    <p>
                        A collection of meta data items associated with the image.
                    </p>
                </xsd:documentation>
            </annotation>
        </element>
        <element name="fault" type="csapi:AsyncAPIFault" minOccurs="0">
            <annotation>
                <xsd:documentation
                    xml:lang="EN"
                    xmlns="http://www.w3.org/1999/xhtml">
                    <p>
                        The details of a fault that may have occurred
                        while creating an image.
                    </p>
                </xsd:documentation>
            </annotation>
        </element>
        <element vc:minVersion="1.1" ref="atom:link" minOccurs="0" maxOccurs="unbounded" />
        <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
    </sequence>
    <attribute type="csapi:UUID" name="id" use="optional">
      <annotation>
        <xsd:documentation
            xml:lang="EN"
            xmlns="http://www.w3.org/1999/xhtml">
          <p>
            The ID of the image.
          </p>
        </xsd:documentation>
      </annotation>
    </attribute>
    <attribute type="xsd:string"      name="name"      use="optional">
      <annotation>
        <xsd:documentation
            xml:lang="EN"
            xmlns="http://www.w3.org/1999/xhtml">
          <p>
            The name of the image.
          </p>
        </xsd:documentation>
      </annotation>
    </attribute>
    <attribute type="xsd:string"  name="tenantId" use="optional">
      <annotation>
        <xsd:documentation
            xml:lang="EN"
            xmlns="http://www.w3.org/1999/xhtml">
          <p>
            A unique ID that identifies the tenant that contains
            the image.
          </p>
        </xsd:documentation>
      </annotation>
    </attribute>
    <attribute type="xsd:string"    name="userId" use="optional">
      <annotation>
        <xsd:documentation
            xml:lang="EN"
            xmlns="http://www.w3.org/1999/xhtml">
          <p>
            A unique ID that identifies the user who created
            the image.
          </p>
        </xsd:documentation>
      </annotation>
    </attribute>
    <attribute type="xsd:dateTime"    name="updated" use="optional">
      <annotation>
        <xsd:documentation
            xml:lang="EN"
            xmlns="http://www.w3.org/1999/xhtml">
          <p>
            A time-stamp identifying the modification time of the
            image.
          </p>
        </xsd:documentation>
      </annotation>
    </attribute>
    <attribute type="xsd:dateTime"    name="created" use="optional">
      <annotation>
        <xsd:documentation
            xml:lang="EN"
            xmlns="http://www.w3.org/1999/xhtml">
          <p>
            A creation time-stamp for the image.
          </p>
        </xsd:documentation>
      </annotation>
    </attribute>
    <attribute type="csapi:Progress"  name="progress"  use="optional">
      <annotation>
        <xsd:documentation
            xml:lang="EN"
            xmlns="http://www.w3.org/1999/xhtml">
          <p>
            The progress of the current image operation.
          </p>
        </xsd:documentation>
      </annotation>
    </attribute>
    <attribute type="csapi:ExtensibleImageStatus" name="status"    use="optional">
      <annotation>
        <xsd:documentation
            xml:lang="EN"
            xmlns="http://www.w3.org/1999/xhtml">
          <p>
            The current state (or <a href="#type_ExtensibleImageStatus"
            title="See definition of ExtensibleImageStatus">status</a>) of the
            image.
          </p>
        </xsd:documentation>
      </annotation>
    </attribute>
    <attribute type="xsd:int"    name="minDisk" use="optional">
      <annotation>
        <xsd:documentation
            xml:lang="EN"
            xmlns="http://www.w3.org/1999/xhtml">
          <p>
              Minimum disk space required for the image in gigabytes.
          </p>
        </xsd:documentation>
      </annotation>
    </attribute>
    <attribute type="xsd:int"    name="minRam"  use="optional">
      <annotation>
        <xsd:documentation
            xml:lang="EN"
            xmlns="http://www.w3.org/1999/xhtml">
          <p>
            The minimum amount of RAM required for the image in
            megabytes.
          </p>
        </xsd:documentation>
      </annotation>
    </attribute>
    <anyAttribute namespace="##other" processContents="lax"/>
  </complexType>

  <complexType name="ImageWithOnlyIDNameLinks">
      <annotation>
          <xsd:documentation
              xml:lang="EN"
              xmlns="http://www.w3.org/1999/xhtml">
              <p>
                  The only allowed attribute for this Image type is
                  the name, ID, and links.  This is used for
                  non-detailed list of images.
              </p>
          </xsd:documentation>
      </annotation>
      <complexContent>
          <restriction base="csapi:Image">
              <sequence>
                  <element ref="atom:link" minOccurs="1" maxOccurs="unbounded" />
                  <any vc:minVersion="1.1" namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
              </sequence>
              <attribute type="csapi:UUID" name="id"   use="required"/>
              <attribute type="xsd:string" name="name" use="required"/>
              <attribute type="xsd:dateTime" name="updated" use="prohibited"/>
              <attribute type="xsd:dateTime" name="created" use="prohibited"/>
              <attribute type="csapi:Progress" name="progress" use="prohibited"/>
              <attribute type="csapi:ExtensibleImageStatus" name="status" use="prohibited"/>
              <anyAttribute namespace="##other" processContents="lax"/>
              <assert vc:minVersion="1.1" test="atom:link[@rel='self']/@href and atom:link[@rel='bookmark']/@href">
                  <annotation>
                      <xsd:documentation
                          xml:lang="EN"
                          xmlns="http://www.w3.org/1999/xhtml">
                          <p>
                              Here the image <strong>MUST</strong>
                              contain a name, an ID, a bookmark link,
                              and a self link.
                          </p>
                      </xsd:documentation>
                  </annotation>
              </assert>
          </restriction>
      </complexContent>
  </complexType>

  <complexType name="Images">
    <sequence>
      <element name="image" type="csapi:Image" minOccurs="0" maxOccurs="1000">
      <annotation>
        <xsd:documentation
            xml:lang="EN"
            xmlns="http://www.w3.org/1999/xhtml">
          <p>
            A collection of images (all details).
          </p>
        </xsd:documentation>
      </annotation>
      </element>
      <element vc:minVersion="1.1" ref="atom:link" minOccurs="0" maxOccurs="unbounded" />
      <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
    </sequence>
    <anyAttribute namespace="##other" processContents="lax"/>
  </complexType>

  <complexType name="ImagesWithOnlyIDsNamesLinks">
      <annotation>
          <xsd:documentation
              xml:lang="EN"
              xmlns="http://www.w3.org/1999/xhtml">
              <p>
                  A collection of images with only IDs, names, and
                  links. This is used for the non-detailed list of
                  images.
              </p>
          </xsd:documentation>
      </annotation>
      <complexContent>
          <restriction base="csapi:Images">
              <sequence>
                  <element name="image" type="csapi:ImageWithOnlyIDNameLinks" minOccurs="0" maxOccurs="1000"/>
                  <element vc:minVersion="1.1" ref="atom:link" minOccurs="0" maxOccurs="unbounded" />
                  <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
              </sequence>
              <anyAttribute namespace="##other" processContents="lax"/>
          </restriction>
      </complexContent>
  </complexType>

  <!-- Simple Types -->
  <simpleType name="ExtensibleImageStatus">
      <annotation>
          <xsd:documentation
              xml:lang="EN"
              xmlns="http://www.w3.org/1999/xhtml">
              <p>
                  An extensible image status type allows all of the
                  strings defined in <a href="#type_ImageStatus"
                  title="See definition of
                  ImageStatus">ImageStatus</a> or an
                  alias prefixed status.
              </p>
          </xsd:documentation>
      </annotation>
      <union memberTypes="csapi:ImageStatus csapi:ExtendedStatus"/>
  </simpleType>

  <simpleType name="ImageStatus">
    <restriction base="xsd:string">
      <enumeration value="UNKNOWN">
        <annotation>
          <xsd:documentation
              xml:lang="EN"
              xmlns="http://www.w3.org/1999/xhtml">
            <p>
              The image is in an unknown state.
            </p>
          </xsd:documentation>
        </annotation>
      </enumeration>
      <enumeration value="ACTIVE">
        <annotation>
          <xsd:documentation
              xml:lang="EN"
              xmlns="http://www.w3.org/1999/xhtml">
            <p>
              All operations have completed successfully, the image is
              available for install.
            </p>
          </xsd:documentation>
        </annotation>
      </enumeration>
      <enumeration value="SAVING">
        <annotation>
          <xsd:documentation
              xml:lang="EN"
              xmlns="http://www.w3.org/1999/xhtml">
            <p>
              The image is being created (or saved).
            </p>
          </xsd:documentation>
        </annotation>
      </enumeration>
      <enumeration value="DELETED">
        <annotation>
          <xsd:documentation
              xml:lang="EN"
              xmlns="http://www.w3.org/1999/xhtml">
            <p>
              The image has been deleted.
            </p>
          </xsd:documentation>
        </annotation>
      </enumeration>
      <enumeration value="ERROR">
        <annotation>
          <xsd:documentation
              xml:lang="EN"
              xmlns="http://www.w3.org/1999/xhtml">
            <p>
              The requested operation has failed.
            </p>
          </xsd:documentation>
        </annotation>
      </enumeration>
    </restriction>
  </simpleType>
</schema>

