<?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:1.0"
        xmlns:rest="urn:switchyard-component-resteasy:config:1.0"
        xmlns:swyd="urn:switchyard-config:switchyard:1.0"
        xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
        elementFormDefault="qualified">

    <import namespace="urn:switchyard-config:switchyard:1.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>
                            <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>
                        </sequence>
                    </choice>
                </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="integer" 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="integer" minOccurs="0" maxOccurs="1">
                        <annotation>
                            <documentation>Proxy Port.</documentation>
                        </annotation>
                    </element>
                </sequence>
            </extension>
        </complexContent>
    </complexType>

</schema>
