<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="urn:ibm:names:ws:provisioning:0.1:core" 
        xmlns="http://www.w3.org/2001/XMLSchema" 
        xmlns:core="urn:ibm:names:ws:provisioning:0.1:core" elementFormDefault="qualified">

    <!--    <import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> -->
   
    <import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
    
    <complexType name="ProvisioningTextType">
        <simpleContent>
            <extension base="string">
                <attribute ref="xml:lang" use="optional"/>
                <attribute name="charset" type="string" default="UTF-8"/>                
            </extension>
        </simpleContent>
    </complexType>
    
    <complexType name="ExtensibleType">
        <annotation>
            <documentation>This is the base type for other extensible types that allow elements and attributes from other namespaces to be used.
            </documentation>
        </annotation>
        <sequence>
            <any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
        </sequence>
        <anyAttribute namespace="##other" processContents="lax"/>
    </complexType>

    <element name="ProvisioningIdentifier" type="core:ProvisioningIdentifierType"/>    
    <complexType name="ProvisioningIdentifierType">    
        <annotation>
            <documentation>Generic identifier for all provisioning related objects.</documentation>
        </annotation>
        <complexContent>
            <extension base="core:ExtensibleType">        
                <attribute name="name" type="string" use="required"/>
            </extension>
        </complexContent>
    </complexType>
    
    <complexType name="ProvisioningIterator">
        <annotation>
            <documentation>Iterator returned from a list request.</documentation>
        </annotation>
        <complexContent>
            <extension base="core:ExtensibleType">        
                <sequence>
                    <element name="identifier" type="core:ProvisioningIdentifierType"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    
    <complexType name="NamespaceSpecifierType"> 
        <annotation>
            <documentation>This type encapsulates a prefix to namespace mapping.</documentation>
        </annotation>    
        <attribute name="uri" type="string" use="required">
            <annotation>
                <documentation>
                  This should be of type anyURI but that type generates different mappings based on the 
                  toolset used which means that the server is not portable, so a string is used instead.
                </documentation>
            </annotation>          
        </attribute>
        <attribute name="prefix" type="string" use="required"/>
    </complexType>
    
    <element name="ProvisioningSelector" type="core:ProvisioningSelectorType"/> 
    <complexType name="ProvisioningSelectorType">
        <annotation>
            <documentation>A selector is used to communicate an XPath expression and an optional set of namespace mappings.</documentation>
        </annotation>    
        <sequence>
            <element name="select" type="string" minOccurs="1"/>
            <element name="namespace" type="core:NamespaceSpecifierType" minOccurs="0" maxOccurs="unbounded"/>
        </sequence>
    </complexType>
    
    <element name="ProvisioningIteratedResult" type="core:ProvisioningIteratedResultType"/>
    <complexType name="ProvisioningIteratedResultType">
        <annotation>
            <documentation>Basic result information from an operation that can return large, iterated, result sets.</documentation>
        </annotation>
        <all>
          <element name="status" type="core:ProvisioningRequestStatusType" minOccurs="1"/>
          <element name="iterator" type="core:ProvisioningIterator" minOccurs="0" maxOccurs="1"/>
        </all>
        <attribute name="remaining" type="int" use="optional"/> 
        <attribute name="size" type="int" use="optional"/> 
    </complexType>
    
    <element name="ProvisionedItemFilter" type="core:ProvisionedItemFilterType"/>
    <complexType name="ProvisionedItemFilterType">
        <annotation>
            <documentation>Filter for provisioned objects.</documentation>
        </annotation>
        <all>
            <element name="target" type="core:ProvisioningIdentifierType" minOccurs="0"/>             
            <element name="owner" type="core:ProvisioningIdentifierType" minOccurs="0"/>                         
            <element name="states" type="core:ProvisioningStateSetType" minOccurs="0"/>                         
            <element name="selector" type="core:ProvisioningSelectorType" minOccurs="0"/>                                     
        </all>
    </complexType>        
            
    <element name="ProvisioningInterval" type="core:ProvisioningIntervalType"/> 
    <complexType name="ProvisioningIntervalType">
        <annotation>
            <documentation>An interval encapsulates a start and end time.</documentation>
        </annotation>    
        <sequence>
            <element name="start" type="dateTime" minOccurs="0" maxOccurs="1"/>
            <element name="end" type="dateTime" minOccurs="0" maxOccurs="1"/>            
        </sequence>
    </complexType>
    
    <element name="ProvisioningIntervalSet" type="core:ProvisioningIntervalSetType"/>
    <complexType name="ProvisioningIntervalSetType">
        <annotation>
            <documentation>A set of ProvisioningInterval instances.</documentation>
        </annotation>
        <sequence>
            <element ref="core:ProvisioningInterval" maxOccurs="unbounded"/>
        </sequence>
    </complexType>
    
    <complexType name="ProvisioningTargetSchema">
        <annotation>
            <documentation>The schema for a target.</documentation>
        </annotation>    
        <sequence>                  
            <element name="root" type="core:ProvisioningSelectorType" minOccurs="0" maxOccurs="1">
                <annotation>
                    <documentation>
                      This is an optional element that allows a server to identify a specific element
                      in the schema as the primary type.  This should only be used when the schema 
                      language for a target does not allow a QName to be used, otherwise the ref
                      attribute should be used.
                    </documentation>
                </annotation>            
            </element>
            <any namespace="##other" id="targetSchema" minOccurs="0"/>
        </sequence>     
        <attribute name="ref" type="QName" use="optional">
            <annotation>
                <documentation>Optionally specify the primary type in the schema.</documentation>
            </annotation>
        </attribute>
        <attribute name="location" type="string" use="optional"> 
            <annotation>
                <documentation>Specify the location of an external schema.</documentation>
            </annotation>        
        </attribute>
        <attribute name="namespace" type="string" use="optional"> 
            <annotation>
                <documentation>Specify the namespace of the schema language.</documentation>
            </annotation> 
        </attribute>
    </complexType>
    
    <element name="ProvisioningTarget" type="core:ProvisioningTargetType"/>
    <complexType name="ProvisioningTargetType">
        <annotation>
            <documentation>A ProvisioningTarget represents a resource that may be provisioned</documentation>
        </annotation>
        <complexContent>
            <extension base="core:ExtensibleType">         
                <sequence>
                    <element name="identifier" type="core:ProvisioningIdentifierType" minOccurs="1" maxOccurs="1"/>
                    <element name="description" type="core:ProvisioningTextType" minOccurs="0" maxOccurs="unbounded"/>
                    <element name="schema" type="core:ProvisioningTargetSchema" minOccurs="0" maxOccurs="unbounded"/>
                </sequence>
            </extension>
        </complexContent>                
    </complexType>
    
    <element name="ProvisioningTargetSet" type="core:ProvisioningTargetSetType"/>
    <complexType name="ProvisioningTargetSetType">
        <annotation>
            <documentation>A set of ProvisioningTarget instances.</documentation>
        </annotation>
        <sequence>
            <element ref="core:ProvisioningTarget" maxOccurs="unbounded"/>
        </sequence>
    </complexType>
    
    <element name="ProvisioningState" type="core:ProvisioningStateType"/>    
    <simpleType name="ProvisioningStateType">
    
        <!--
        <union>
            <simpleType>
                <restriction base="string">
                    <enumeration value="created"/>  
                    <enumeration value="active"/>                    
                    <enumeration value="suspended"/>
                    <enumeration value="locked"/>
                    <enumeration value="terminated"/>
                </restriction>
            </simpleType>
            <simpleType>
                <restriction base="string"/>
            </simpleType>
        </union>
        -->

        <restriction base="string">
            <enumeration value="created"/>  
            <enumeration value="active"/>                    
            <enumeration value="suspended"/>
            <enumeration value="locked"/>
            <enumeration value="terminated"/>
        </restriction>
       
    </simpleType>
    
    <element name="ProvisioningStateSet" type="core:ProvisioningStateSetType"/>
    <complexType name="ProvisioningStateSetType">
        <annotation>
            <documentation>A set of ProvisioningState instances.</documentation>
        </annotation>
        <sequence>
            <element ref="core:ProvisioningState" minOccurs="0" maxOccurs="unbounded"/>
        </sequence>
    </complexType>
    
    <complexType name="ProvisioningOperation">
        <annotation>
            <documentation>Container for any type from the API schema.</documentation>
        </annotation>    
        <sequence>
            <any id="operation" namespace="urn:ibm:names:ws:provisioning:0.1:api"/>
        </sequence>
    </complexType>
    
    <element name="ProvisioningEvent" type="core:ProvisioningEventType"/>
    <complexType name="ProvisioningEventType">
        <annotation>
            <documentation>An event on a provisioned item.</documentation>
        </annotation>
        <complexContent>
            <extension base="core:ExtensibleType">         
                <sequence>
                    <element name="reason" type="core:ProvisioningRequestStatusType" minOccurs="0"/>
                    <element name="state" type="core:ProvisioningStateType" minOccurs="0"/>
                    <element name="date" type="dateTime" minOccurs="0"/>
                    <element name="description" type="core:ProvisioningTextType" minOccurs="0" maxOccurs="unbounded"/>
                    <element name="actor" type="core:ProvisioningIdentifierType" minOccurs="0"/>
                    <element name="request" type="core:ProvisioningOperation" minOccurs="0"/>
                    <element name="response" type="core:ProvisioningOperation" minOccurs="0"/>                    
                </sequence> 
            </extension>
        </complexContent>                
    </complexType>
    
    <element name="ProvisioningEventSet" type="core:ProvisioningEventSetType"/>    
    <complexType name="ProvisioningEventSetType">
        <annotation>
            <documentation>A set of ProvisioningEvent instances.</documentation>
        </annotation>
        <sequence>
            <element name="provisionedItem" type="core:ProvisioningIdentifierType" minOccurs="1"/>                
            <element name="interval" type="core:ProvisioningIntervalType" minOccurs="0"/>        
            <element name="event" type="core:ProvisioningEventType" minOccurs="0" maxOccurs="unbounded"/>
        </sequence>
    </complexType>
    
    <complexType name="ProvisioningServiceParametersType">
        <annotation>
            <documentation>Container for generic parameters used for a provisioning request or return values.</documentation>
        </annotation>    
        <sequence>
            <any id="serviceParameters"/>
        </sequence>
    </complexType>
    
    <element name="ProvisionedItem" type="core:ProvisionedItemType"/>
    <complexType name="ProvisionedItemType">
        <annotation>
            <documentation>A ProvisionedItem holds the state of a provisioned target or request.</documentation>
        </annotation>
        <complexContent>
            <extension base="core:ExtensibleType">          
                <sequence>
                    <element name="identifier" type="core:ProvisioningIdentifierType" minOccurs="1" maxOccurs="1"/>
                    <element name="target" type="core:ProvisioningIdentifierType" minOccurs="1" maxOccurs="1"/>
                    <element name="owner" type="core:ProvisioningIdentifierType" minOccurs="0" maxOccurs="1"/>            
                    <element name="state" type="core:ProvisioningStateType" minOccurs="0"/>
                    <element name="parameters" type="core:ProvisioningServiceParametersType" minOccurs="0"/>
                </sequence>
            </extension>
        </complexContent>                 
    </complexType>
    
    <element name="ProvisionedItemSet" type="core:ProvisionedItemSetType"/>
    <complexType name="ProvisionedItemSetType">
        <annotation>
            <documentation>A set of ProvisionedItem instances.</documentation>
        </annotation>
        <sequence>
            <element ref="core:ProvisionedItem" minOccurs="0" maxOccurs="unbounded"/>
        </sequence>
    </complexType>
    
    <simpleType name="ProvisioningStatusCode">
        <restriction base="string">
            <enumeration value="success"/>
            <enumeration value="inProcess"/>
            <enumeration value="pending"/>            
            <enumeration value="badRequest"/>
            <enumeration value="badState"/>            
            <enumeration value="busy"/>
            <enumeration value="expired"/>          
            <enumeration value="timeout"/>                      
            <enumeration value="unavailable"/>
            <enumeration value="invalidExpression"/>    
            <enumeration value="serverError"/>            
            <enumeration value="unsupportedOperation"/>
            <enumeration value="notAuthorized"/>
            <enumeration value="schemaViolation"/>
            <enumeration value="unsupportedSchema"/>
            <enumeration value="unrecognizedIdentifier"/>
            <enumeration value="objectUnavailable"/>            
            <enumeration value="targetUnavailable"/>
            <enumeration value="targetReportedError"/>
            <enumeration value="incompleteModification"/>
        </restriction>
    </simpleType>
    
    <element name="ProvisioningRequestStatus" type="core:ProvisioningRequestStatusType"/>
    <complexType name="ProvisioningRequestStatusType">
        <annotation>
            <documentation>The status returned from a provisioning operation.</documentation>
        </annotation>
        <complexContent>
            <extension base="core:ExtensibleType">         
                <sequence>
                    <element name="requestId" type="string" minOccurs="0" maxOccurs="1"/>
                    <element name="code" type="core:ProvisioningStatusCode" minOccurs="1"/>
                    <element name="description" type="core:ProvisioningTextType" minOccurs="0" maxOccurs="unbounded"/>
                </sequence>
            </extension>
        </complexContent>                
    </complexType>
    
    <complexType name="ProvisioningObjectStatusType"> 
        <annotation>
            <documentation>Type used to return status for a specific identified object.</documentation>
        </annotation>    
        <sequence>
            <element name="status" type="core:ProvisioningRequestStatusType" minOccurs="1"/>
            <element name="identifier" type="core:ProvisioningIdentifierType" minOccurs="0"/>
        </sequence>
    </complexType> 
    
</schema>
