<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--

    Copyright 2016-2018 Red Hat, Inc. and/or its affiliates
    and other contributors as indicated by the @author tags.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<xs:schema xmlns="urn:jboss:galleon:provisioned-state:1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
  attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:jboss:galleon:provisioned-state:1.0"
  version="2.0">

  <xs:element name="installation" type="installationType" />

  <xs:complexType name="installationType">
    <xs:annotation>
      <xs:documentation>
        Describes the specification of the target installation.
      </xs:documentation>
    </xs:annotation>
    <xs:choice maxOccurs="unbounded" minOccurs="1">
      <xs:element name="feature-pack" type="feature-packType" />
      <xs:element name="config" type="configType" />
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="feature-packType">
    <xs:annotation>
      <xs:documentation>
        Describes installed feature-pack.
      </xs:documentation>
    </xs:annotation>
    <xs:choice maxOccurs="1" minOccurs="0">
      <xs:element name="packages" type="packagesType" />
    </xs:choice>
    <xs:attributeGroup ref="gavAttributeGroup"/>
  </xs:complexType>

  <xs:attributeGroup name="gavAttributeGroup">
    <xs:attribute name="groupId" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          The groupId of the feature-pack artifact.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="artifactId" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          The artifactId of the feature-pack artifact.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="version" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          The version of the feature-pack artifact.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:attributeGroup>

  <xs:complexType name="packagesType">
    <xs:annotation>
      <xs:documentation>
        List of installed packages.
      </xs:documentation>
    </xs:annotation>
    <xs:choice maxOccurs="unbounded" minOccurs="0">
      <xs:element name="package" type="packageType" />
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="packageType">
    <xs:annotation>
      <xs:documentation>
        Names a package
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="name" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          Package name
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>


  <xs:complexType name="configType">
    <xs:annotation>
      <xs:documentation>
        Describes configuration in a generic way.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="props" type="propsType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="feature-pack" type="featurePackConfigType" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="name" type="xs:string" use="optional">
      <xs:annotation>
        <xs:documentation>
          Configuration name
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="model" type="xs:string" use="optional">
      <xs:annotation>
        <xs:documentation>
          Configuration model name
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="propsType">
    <xs:annotation>
      <xs:documentation>
        Describes configuration properties
      </xs:documentation>
    </xs:annotation>
    <xs:choice maxOccurs="unbounded" minOccurs="0">
      <xs:element name="prop" type="propType" />
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="propType">
    <xs:annotation>
      <xs:documentation>
        Describes configuration property
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="name" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          Property name
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="value" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          Property value
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="featurePackConfigType">
    <xs:choice>
      <xs:element name="spec" type="specConfigType" maxOccurs="unbounded"/>
    </xs:choice>
    <xs:attributeGroup ref="gavAttributeGroup"/>
  </xs:complexType>

  <xs:complexType name="specConfigType">
    <xs:choice>
      <xs:element name="feature" type="featureConfigType" maxOccurs="unbounded"/>
    </xs:choice>
    <xs:attribute name="name" type="xs:string"/>
  </xs:complexType>

  <xs:complexType name="featureConfigType">
    <xs:choice>
      <xs:element name="param" type="propType" minOccurs="0" maxOccurs="unbounded"/>
    </xs:choice>
    <xs:attribute name="id" type="xs:string"/>
  </xs:complexType>

</xs:schema>