<?xml version="1.0" encoding="UTF-8"?>
<ae:configurations xmlns:ae="http://agavi.org/agavi/config/global/envelope/1.0" xmlns="http://icinga.org/appkit/config/parts/routing/1.0">
    <ae:configuration context="web">
        <routes>
            
            <!-- INDEX -->
            <route name="index_page" pattern="^/$" module="Web" action="Icinga.PortalView"/>
            
            <route name="modules" pattern="^/modules" stop="false">
            </route>
            
            <route name="styles" pattern="^/styles" module="%actions.default_module%" action="Widgets.SquishLoader">
                <route name=".css" pattern="^/css" output_type="css" />
            </route>


            <route module="Api" name="icinga.api" pattern="^/web/api" action="ApiSearch">
            
                <route name=".checkUrlAuth" stop="false" pattern="authkey=(authkey:[^/]*)">
                    <callbacks>
                        <callback class="IcingaApiAuthentificationRoutingCallback" />
                    </callbacks>
                </route>
            
                <route name=".dataStore" output_type="html" stop="true"
                    pattern="^/dataStore" action="ApiDataStoreProvider" api_provider="true" />
                <route name=".icingaStatus" output_type="json" stop="false"
                    pattern="^/icinga/statusProvider" action="IcingaInstanceController" />
                    
                <route name=".command" stop="false" pattern="^/cmd/"
                    output_type="json" action="ApiCommand">
                    <route name=".cmdParam" stop="false" pattern="cmd=(command:[^/]*)/" />
                    <route name=".authkey" stop="false" pattern="authkey=(authkey:[^/]*)" />
                    <route name=".data" stop="false" pattern="data=(data:[^/]*)" />
                    <route name=".target" stop="false" pattern="target=(target:[^/]*)" />
                </route>
                
                <route name=".commandInfo" pattern="^/cmdInfo" stop="false" action="ApiCommandInfo" output_type="json">
                    <route name=".cmdParam" stop="false" pattern="cmd=(command:[^/]*)/" />
                    <route name=".output" stop="true" pattern="(output:json|xml)$"
                        output_type="${output}">
                        <ignores>
                            <ignore>output</ignore>
                        </ignores>
                    </route>
                </route>
                
                <route name=".relation" pattern="^/relation" stop="false" action="RelationProvider" output_type="json">
                    <route name=".objectId" stop="true" pattern="^/(objectId:[0-9]+)" />
                </route>
                
                <route name=".sla" pattern="^/sla" output_type="json" action="SLAProvider">
                    <route name=".starttime" stop="false" pattern="start=(starttime:\d*)" />
                    <route name=".endtime" stop="false" pattern="end=(endtime:\d*)" />
                    <route name=".hostOnlyFlag" stop="false" pattern="(hostsonly:hostsOnly)" />
                    <route name=".servicesOnlyFlag" stop="false" pattern="(servicesonly:servicesOnly)" />
                    <route name=".hostNamePattern" stop="false" pattern="hostnames[(hostnames:(.*?))]" />
                    <route name=".serviceNamePattern" stop="false" pattern="servicenames[(servicenames:(.*?))]" />
                    <route name=".hostGroupPattern" stop="false" pattern="hostgroups[(hostgroups:(.*?))]" />
                    <route name=".serviceGroupPattern" stop="false" pattern="servicegroups[(servicegroups:(.*?))]" />
                    <route name=".ids" stop="false" pattern="ids[(ids:(.*?))]" />
                    <route name=".instances" stop="false" pattern="instances[(instanceIds:(.*?))]" />
                    <route name=".timespan" stop="false" pattern="timespan[(timespan:(.*?))]" />
                    
                    <route name=".output" stop="true" pattern="(output:json|xml|soap|rest)$"
                        output_type="${output}">
                        <ignores>
                            <ignore>output</ignore>
                        </ignores>
                    </route>
                </route>
                <route name=".target" stop="false"
                    pattern="^/(target:instance|host|service|hostgroup|servicegroup|customvariable|contact|contactgroup|timeperiod|hoststatus|servicestatus|hosttimes|servicetimes|config|program|log|host_status_summary|service_status_summary|host_status_history|service_status_history|host_parents|notifications|hostgroup_summary|servicegroup_summary|command|downtime|comment|servicecomment|hostcomment|status|host_service)/">
                    <!-- Filter will be split by AppKitUrlFilterValidator -->
                    <route name=".authkey" stop="false" pattern="authkey=(authkey:[^/]*)" />
                    <route name=".filter" stop="false" pattern="filter[(filter:.*)]" />
                    <route name=".group" stop="false" pattern="group[(groups:.*?)]" />
                    <route name=".column" stop="false" pattern="columns[(columns:(.*?))]" />
                    <route name=".order" stop="false"
                        pattern="order[(order_col:\w*);(order_dir:\w*)]" />
                    <route name=".limit" stop="false"
                        pattern="limit[({limit_start:\d*};)?(limit:\d*)]" />
                    <route name=".countcolumn" stop="false"
                        pattern="countColumn=(countColumn:\w*)" />
                    <route name=".connection" stop="false"
                        pattern="connection=(connection:\w*)" />
                    <route name=".withSLA" stop="false" pattern="withSLA=(withSLA:\d)" />
                    <route name=".withMeta" stop="false" pattern="withMeta=(withMeta:\d)" />
                    <route name=".output" stop="true" pattern="(output:json|xml|soap|rest)$"
                        output_type="${output}">
                        <ignores>
                            <ignore>output</ignore>
                        </ignores>
                    </route>

                    <!-- Define the ouput type -->
                </route>
                <route name=".output" stop="true" pattern="(output:json|xml)$"
                    output_type="${output}">
                    <ignores>
                        <ignore>output</ignore>
                    </ignores>
                </route>
            
            </route>

        </routes>
    </ae:configuration>
    
    <ae:configuration context="console">
        <routes>
            <route name="modules" pattern="">   
                <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="routing.modules.xml" xpointer="xmlns(r=http://icinga.org/appkit/config/parts/routing/1.0) xpointer(//r:module_routes/r:configuration[@context='console']/node())">
                        <xi:fallback></xi:fallback>
                </xi:include>
            </route>
        </routes>
    </ae:configuration>
    
    <!--
    <ae:configuration context="soap">
        <routes>
            <route name="modules" pattern="^/modules">  
                <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="routing.modules.xml" xpointer="xmlns(r=http://icinga.org/appkit/config/parts/routing/1.0) xpointer(//r:module_routes/r:configuration[@context='soap']/node())">
                        <xi:fallback></xi:fallback>
                </xi:include>
            </route>
            
            <route name="serviceMain" pattern="getIcingaAPI" action="Icinga.ApiSearch" module="Web"/>
        </routes>
    </ae:configuration>
    -->
    
    <ae:configuration context="testing">
        <routes>
            <route name="modules" pattern="^/modules">  
                <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="routing.modules.xml" xpointer="xmlns(r=http://icinga.org/appkit/config/parts/routing/1.0) xpointer(//r:module_routes/r:configuration[@context='testing']/node())">
                        <xi:fallback></xi:fallback>
                </xi:include>
            </route>
        </routes>
    </ae:configuration>
        
</ae:configurations>
