<?xml version="1.0" encoding="UTF-8"?>
<!--
 - Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors.
 - 
 - 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.
 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="urn:switchyard-component-resteasy:config:2.0"
        xmlns:rest="urn:switchyard-component-resteasy:config:2.0"
        xmlns:swyd="urn:switchyard-config:switchyard:2.0"
        xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
        elementFormDefault="qualified">

    <import namespace="urn:switchyard-config:switchyard:2.0"/>
    <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"/>

    <element name="binding.rest" type="rest:RESTBindingType" substitutionGroup="swyd:binding.switchyard"/>
    <complexType name="RESTBindingType">
        <complexContent>
            <extension base="swyd:SwitchYardBindingType">
                <sequence>
                    <element name="contextMapper" type="swyd:ContextMapperType"  minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Specify the ContextMapper to be used.</documentation>
                        </annotation>
                    </element>
                    <element name="messageComposer" type="swyd:MessageComposerType" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Specify the MessageComposer to be used.</documentation>
                        </annotation>
                    </element>
                    <element name="interfaces" type="string" minOccurs="1" maxOccurs="1">
                        <annotation>
                            <documentation>A comma separated list of interfaces or abstract/empty classes with REST annotations.</documentation>
                        </annotation>
                    </element>
                    <choice>
                        <element name="contextPath" type="string" minOccurs="0" maxOccurs="1">
                            <annotation>
                                <documentation>A URI string that represents the root context where this service is hosted.</documentation>
                            </annotation>
                        </element>
                        <sequence>
                            <element name="address" type="string" minOccurs="0" maxOccurs="1">
                                <annotation>
                                    <documentation>A URL that points to the root path of resources. This is only applicable for Reference bindings. It is optional and if not specified will default to http://127.0.0.1:8080/.</documentation>
                                </annotation>
                            </element>
                            <element name="timeout" type="swyd:propInteger" minOccurs="0" maxOccurs="1">
                                <annotation>
                                    <documentation>The request's time-out value in milliseconds.</documentation>
                                </annotation>
                            </element>
                            <choice>
                                <element name="basic" type="rest:BasicAuthenticationType" minOccurs="0" maxOccurs="1"/>
                                <element name="ntlm" type="rest:NTLMAuthenticationType" minOccurs="0" maxOccurs="1"/>
                            </choice>
                            <element name="proxy" type="rest:ProxyType" minOccurs="0" maxOccurs="1">
                                <annotation>
                                    <documentation>Http proxy settings.</documentation>
                                </annotation>
                            </element>
                            <element name="ssl" type="rest:SSLContextType" minOccurs="0" maxOccurs="1">
                                <annotation>
                                    <documentation>Http SSL Context settings.</documentation>
                                </annotation>
                            </element>
                        </sequence>
                    </choice>
                    <element name="contextParams" type="rest:ContextParamsType" minOccurs="0" maxOccurs="1"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="BasicAuthenticationType">
        <complexContent>
            <extension base="sca:CommonExtensionBase">
                <sequence>
                    <element name="user" type="string" maxOccurs="1">
                        <annotation>
                            <documentation>User name.</documentation>
                        </annotation>
                    </element>
                    <element name="password" type="string" maxOccurs="1">
                        <annotation>
                            <documentation>Password.</documentation>
                        </annotation>
                    </element>
                    <element name="realm" type="string" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Authentication Realm.</documentation>
                        </annotation>
                    </element>
                    <element name="host" type="string" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Authentication Host.</documentation>
                        </annotation>
                    </element>
                    <element name="port" type="swyd:propInteger" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Authentication Port.</documentation>
                        </annotation>
                    </element>
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="NTLMAuthenticationType">
        <complexContent>
            <extension base="rest:BasicAuthenticationType">
                <sequence>
                    <element name="domain" type="string" maxOccurs="1">
                        <annotation>
                            <documentation>The NTLM Domain.</documentation>
                        </annotation>
                    </element>
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="ProxyType">
        <complexContent>
            <extension base="sca:CommonExtensionBase">
                <sequence>
                    <element name="host" type="string" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Proxy Host.</documentation>
                        </annotation>
                    </element>
                    <element name="port" type="swyd:propInteger" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Proxy Port.</documentation>
                        </annotation>
                    </element>
                    <element name="user" type="string" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Proxy user name.</documentation>
                        </annotation>
                    </element>
                    <element name="password" type="string" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Proxy password.</documentation>
                        </annotation>
                    </element>
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="SSLContextType">
        <complexContent>
            <extension base="sca:CommonExtensionBase">
                <sequence>
                    <element name="verifier" type="string" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>SSL hostname verifier.</documentation>
                        </annotation>
                    </element>
                    <element name="keystore" type="string" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>SSL keystore store.</documentation>
                        </annotation>
                    </element>
                    <element name="keystorePass" type="string" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>SSL keystore password.</documentation>
                        </annotation>
                    </element>
                    <element name="truststore" type="string" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>SSL truststore store.</documentation>
                        </annotation>
                    </element>
                    <element name="truststorePass" type="string" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>SSL truststore password.</documentation>
                        </annotation>
                    </element>
                </sequence>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="ContextParamsType">
        <complexContent>
            <extension base="sca:CommonExtensionBase">
                <sequence>
                    <element name="contextParam" type="rest:ContextParamType" minOccurs="0" maxOccurs="unbounded">
                        <annotation>
                            <documentation>Context parameters.</documentation>
                        </annotation>
                    </element>
                </sequence>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="ContextParamType">
        <attribute name="name" type="string" use="required"/>
        <attribute name="value" type="string" use="required"/>
    </complexType>
</schema>
