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

<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2012, Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags. See the copyright.txt file in the
  ~ distribution for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="urn:jboss:cli:1.3"
           targetNamespace="urn:jboss:cli:1.3"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
        >


    <xs:element name="jboss-cli">
        <xs:annotation>
            <xs:documentation>
                Root element for the JBoss Command Line Interface configuration.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="default-controller" minOccurs="0"/>
                <xs:element ref="validate-operation-requests" minOccurs="0"/>
                <xs:element ref="history" minOccurs="0"/>

                <xs:element name="resolve-parameter-values" type="xs:boolean" minOccurs="0" maxOccurs="1" default="false">
                    <xs:annotation>
                        <xs:documentation>
                            Whether to resolve system properties specified as command argument (or operation parameter)
                            values before sending the operation request to the controller or let the resolution happen
                            on the server side.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>

                <xs:element ref="connection-timeout" minOccurs="0" maxOccurs="1"/>

                <xs:element ref="ssl" minOccurs="0" maxOccurs="1"/>
                
                <xs:element ref="silent" minOccurs="0" maxOccurs="1"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="default-controller">
        <xs:annotation>
            <xs:documentation>
                This element contains the configuration of the default controller to connect to
                when the connect command is executed w/o arguments.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="host" type="xs:string" minOccurs="0" default="localhost"/>
                <xs:element name="port" type="xs:int" minOccurs="0" default="9999"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="validate-operation-requests" type="xs:boolean" default="true">
        <xs:annotation>
            <xs:documentation>
                Indicates whether the parameter list of the operation reuqests
                should be validated before the requests are sent to the controller
                for the execution.
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:element name="history">
        <xs:annotation>
            <xs:documentation>
                This element contains the configuration for the commands and operations history log.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="enabled" type="xs:boolean" minOccurs="0" default="true"/>
                <xs:element name="file-name" type="xs:string" minOccurs="0" default=".jboss-cli-history"/>
                <xs:element name="file-dir" type="xs:string" minOccurs="0" default="${user.home}"/>
                <xs:element name="max-size" type="xs:int" minOccurs="0" default="500"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="connection-timeout" type="xs:int" default="5000">
        <xs:annotation>
            <xs:documentation>
                The time allowed to establish a connection with the controller.
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:element name="ssl">
        <xs:annotation>
            <xs:documentation>
                This element contains the configuration for the Key and Trust stores
                used for SSL.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="vault" type="vaultType" minOccurs="0" />
                <xs:element name="key-store" type="xs:string" minOccurs="0" />
                <xs:element name="key-store-password" type="xs:string" minOccurs="0" />
                <xs:element name="alias" type="xs:string" minOccurs="0" />
                <xs:element name="key-password" type="xs:string" minOccurs="0" />
                <xs:element name="trust-store" type="xs:string" minOccurs="0" />
                <xs:element name="trust-store-password" type="xs:string" minOccurs="0" />
                <xs:element name="modify-trust-store" type="xs:boolean" default="true" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>
                            Setting to true will cause the CLI to prompt when unrecognised certificates are received
                            and allow them to be stored in the truststore.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <xs:element name="silent" type="xs:boolean" default="false">
        <xs:annotation>
            <xs:documentation>
                Whether to write info and error messages to the terminal output.
                Even if the value is false, the messages will still be logged
                using the logger if its configuration allows and/or if the
                output target was specified as part of the command line using '>'.
            </xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:complexType name="vaultType">
        <xs:annotation>
            <xs:documentation>
                Element of this type points to a file with vault configuration.
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="file" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>
                    Absolute or relative file system path to the XML file
                    containing the vault configuration.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="relative-to" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation>
                    One of the system-provided named paths (such as jboss.home.dir,
                    user.home, user.dir) relative to which the absolute path
                    will be calculated for the path specified in the file attribute.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>
</xs:schema>
