<service-logic
    xmlns='http://www.onap.org/sdnc/svclogic'
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='GENERIC-RESOURCE-API' version='${project.version}'>
    <method rpc='validate-sdwan-vf-vpn-input-parameters' mode='sync'>
        <block atomic="true">
            <switch test='`$vf-module-topology-operation-input.sdnc-request-header.svc-action`'>
                <outcome value=''>
                    <return status='failure'>
                        <parameter name='ack-final' value='Y'/>
                        <parameter name="error-code" value="500" />
                        <parameter name="error-message" value="sdnc-request-header.svc-request-id is a required input" />
                    </return>
                </outcome>
            </switch>
            <switch test='`$service-data.vnfs.vnf_length`'>
                <outcome value=''>
                    <return status='failure'>
                        <parameter name='ack-final' value='Y'/>
                        <parameter name="error-code" value="500" />
                        <parameter name="error-message" value="vnf entry not found in service-data" />
                    </return>
                </outcome>
            </switch>
            <for index='idx' start='0' end='`$service-data.vnfs.vnf_length`' >
                <switch test="`$service-data.vnfs.vnf[$idx].vnf-id == $vf-module-topology-operation-input.vnf-information.vnf-id`">
                    <outcome value='true'>
                        <set>
                            <parameter name='vnf-index' value='`$idx`' />
                        </set>
                    </outcome>
                </switch>
            </for>
            <switch test='`$vnf-index`'>
                <outcome value=''>
                    <return status='failure'>
                        <parameter name='ack-final' value='Y'/>
                        <parameter name="error-code" value="500" />
                        <parameter name="error-message" value="vnf id not found in service-data" />
                    </return>
                </outcome>
            </switch>
            <switch test='`$vf-module-topology-operation-input.sdnc-request-header.svc-action`'>
                <outcome value='create'>
                    <block atomic="true">
                        <switch test='`$vf-module-topology-operation-input.request-information.request-action`'>
                            <outcome value='CreateSDWANVpnInstance'>
                                <block atomic="true">
                                    <for index="i" start="0" end="`$vf-module-topology-operation-input.vf-module-request-input.vf-module-input-parameters.param_length`">
                                        <block>
                                            <set>
                                                <parameter name='tmp.name' value='' />
                                                <parameter name='tmp.value' value='' />
                                            </set>
                                            <set>
                                                <parameter name='tmp.name' value="`$vf-module-topology-operation-input.vf-module-request-input.vf-module-input-parameters.param[$i].name`"/>
                                                <parameter name='tmp.value' value="`$vf-module-topology-operation-input.vf-module-request-input.vf-module-input-parameters.param[$i].value`"/>
                                            </set>
                                            <switch test="`$tmp.name`">
                                                <outcome value='name'>
                                                    <switch test="`$tmp.value`">
                                                        <outcome value=''>
                                                            <return status='failure'>
                                                                <parameter name='ack-final' value='Y'/>
                                                                <parameter name="error-code" value="500" />
                                                                <parameter name="error-message" value="`'vf-module-request-input.vf-module-input-parameters.param '+ $tmp.name +' is a required input'`" />
                                                            </return>
                                                        </outcome>
                                                    </switch>
                                                </outcome>
                                                <outcome value='topology'>
                                                    <switch test="`$tmp.value`">
                                                        <outcome value=''>
                                                            <return status='failure'>
                                                                <parameter name='ack-final' value='Y'/>
                                                                <parameter name="error-code" value="500" />
                                                                <parameter name="error-message" value="`'vf-module-request-input.vf-module-input-parameters.param '+ $tmp.name +' is a required input'`" />
                                                            </return>
                                                        </outcome>
                                                    </switch>
                                                </outcome>
                                                <outcome value=''>
                                                    <return status='failure'>
                                                        <parameter name='ack-final' value='Y'/>
                                                        <parameter name="error-code" value="500" />
                                                        <parameter name="error-message" value="`'vf-module-topology-operation-input.vf-module-request-input.vf-module-input-parameters.param[' + $i + ']' + '.name is a required input'`" />
                                                    </return>
                                                </outcome>
                                            </switch>
                                        </block>
                                    </for>
                                </block>
                            </outcome>
                            <outcome value='Other'>
                                <return status='failure'>
                                    <parameter name='ack-final' value='Y'/>
                                    <parameter name="error-code" value="500" />
                                    <parameter name="error-message" value="request-information.request-action is required to be SOTN CreateVPNNetworkInstance for svc-action=create" />
                                </return>
                            </outcome>
                        </switch>
                    </block>
                </outcome>
                <outcome value='activate'>
                    <switch test='`$vf-module-topology-operation-input.request-information.request-action`'>
                        <outcome value='ActivateSDWANVpnInstance'>
                            <block atomic="true">
                                <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils' method='requiredParameters' >
                                    <parameter name="vf-module-topology-operation-input.vf-module-information.vf-module-id" value="$vf-module-topology-operation-input.vf-module-information.vf-module-id"/>
                                </execute>
                                <switch test="`$vf-module-topology-operation-input.vf-module-information.vf-module-id`">
                                    <outcome value=''>
                                        <return status='failure'>
                                            <parameter name='ack-final' value='Y'/>
                                            <parameter name="error-code" value="500" />
                                            <parameter name="error-message" value="network-request-input.network-input-parameters.name is a required input" />
                                        </return>
                                    </outcome>
                                </switch>
                                <switch test='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module_length`'>
                                    <outcome value=''>
                                        <return status='failure'>
                                            <parameter name='ack-final' value='Y'/>
                                            <parameter name="error-code" value="500" />
                                            <parameter name="error-message" value="vf-module-topology-operation-input.vf-module-request-input.vf-module-id not found in service-data" />
                                        </return>
                                    </outcome>
                                    <outcome value='Other'>
                                        <block atomic="true">
                                            <for index='nidx' start='0' end='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module_length`' >
                                                <switch test="`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$nidx].vf-module-id == $vf-module-topology-operation-input.vf-module-information.vf-module-id`">
                                                    <outcome value='true'>
                                                        <block atomic="true">
                                                            <set>
                                                                <parameter name='tmp.vidx' value='`$nidx`' />
                                                                <parameter name='ctx.vf-module-data.' value='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$nidx].vf-module-data.`' />
                                                            </set>
                                                        </block>
                                                    </outcome>
                                                </switch>
                                            </for>
                                            <switch test="`$tmp.vidx`">
                                                <outcome value=''>
                                                    <return status='failure'>
                                                        <parameter name='ack-final' value='Y'/>
                                                        <parameter name="error-code" value="500" />
                                                        <parameter name="error-message" value="vf-module-topology-operation-input.vf-module-request-input.vf-module-id not found in service-data" />
                                                    </return>
                                                </outcome>
                                            </switch>
                                        </block>
                                    </outcome>
                                </switch>
                                <switch test='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$tmp.vidx].vf-module-data.vf-module-level-oper-status.order-status`'>
                                    <outcome value='Created'>
                                        <block atomic="true"></block>
                                    </outcome>
                                    <outcome value='Other'>
                                        <return status='failure'>
                                            <parameter name='ack-final' value='Y'/>
                                            <parameter name="error-code" value="500" />
                                            <parameter name="error-message" value="`'vf-module is not in appropriate state for activate. Current state is ' + $service-data.vf-modules.vf-module[$tmp.nidx].vf-module-data.vf-module-level-oper-status.order-status`" />
                                        </return>
                                    </outcome>
                                </switch>
                            </block>
                        </outcome>
                        <outcome value='Other'>
                            <return status='failure'>
                                <parameter name='ack-final' value='Y'/>
                                <parameter name="error-code" value="500" />
                                <parameter name="error-message" value="request-information.request-action is required to be SOTN ActivateVPNNetworkInstance for svc-action=activate" />
                            </return>
                        </outcome>
                    </switch>
                </outcome>
                <outcome value='deactivate'>
                    <switch test='`$vf-module-topology-operation-input.request-information.request-action`'>
                        <outcome value='DeactivateSDWANVpnInstance'>
                            <block atomic="true">
                                <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils' method='requiredParameters' >
                                    <parameter name="vf-module-topology-operation-input.vf-module-information.vf-module-id" value="$vf-module-topology-operation-input.vf-module-information.vf-module-id"/>
                                </execute>
                                <switch test="`$vf-module-topology-operation-input.vf-module-information.vf-module-id`">
                                    <outcome value=''>
                                        <return status='failure'>
                                            <parameter name='ack-final' value='Y'/>
                                            <parameter name="error-code" value="500" />
                                            <parameter name="error-message" value="network-request-input.network-input-parameters.name is a required input" />
                                        </return>
                                    </outcome>
                                </switch>
                                <switch test='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module_length`'>
                                    <outcome value=''>
                                        <return status='failure'>
                                            <parameter name='ack-final' value='Y'/>
                                            <parameter name="error-code" value="500" />
                                            <parameter name="error-message" value="vf-module-topology-operation-input.vf-module-request-input.vf-module-id not found in service-data" />
                                        </return>
                                    </outcome>
                                    <outcome value='Other'>
                                        <block atomic="true">
                                            <for index='nidx' start='0' end='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module_length`' >
                                                <switch test="`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$nidx].vf-module-id == $vf-module-topology-operation-input.vf-module-information.vf-module-id`">
                                                    <outcome value='true'>
                                                        <block atomic="true">
                                                            <set>
                                                                <parameter name='tmp.vidx' value='`$nidx`' />
                                                                <parameter name='ctx.vf-module-data.' value='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$nidx].vf-module-data.`' />
                                                            </set>
                                                        </block>
                                                    </outcome>
                                                </switch>
                                            </for>
                                            <switch test="`$tmp.vidx`">
                                                <outcome value=''>
                                                    <return status='failure'>
                                                        <parameter name='ack-final' value='Y'/>
                                                        <parameter name="error-code" value="500" />
                                                        <parameter name="error-message" value="vf-module-topology-operation-input.vf-module-request-input.vf-module-id not found in service-data" />
                                                    </return>
                                                </outcome>
                                            </switch>
                                        </block>
                                    </outcome>
                                </switch>
                                <switch test='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$tmp.vidx].vf-module-data.vf-module-level-oper-status.order-status`'>
                                    <outcome value='Active'>
                                        <block atomic="true"></block>
                                    </outcome>
                                    <outcome value='Other'>
                                        <return status='failure'>
                                            <parameter name='ack-final' value='Y'/>
                                            <parameter name="error-code" value="500" />
                                            <parameter name="error-message" value="`'vf-module is not in appropriate state for deactivate. Current state is ' + $service-data.vf-modules.vf-module[$tmp.nidx].vf-module-data.vf-module-level-oper-status.order-status`" />
                                        </return>
                                    </outcome>
                                </switch>
                            </block>
                        </outcome>
                        <outcome value='Other'>
                            <return status='failure'>
                                <parameter name='ack-final' value='Y'/>
                                <parameter name="error-code" value="500" />
                                <parameter name="error-message" value="request-information.request-action is required to be SOTN DeactivateVPNNetworkInstance for svc-action=deactivate" />
                            </return>
                        </outcome>
                    </switch>
                </outcome>
                <outcome value='delete'>
                    <switch test='`$vf-module-topology-operation-input.request-information.request-action`'>
                        <outcome value='DeleteSDWANVpnInstance'>
                            <block atomic="true">
                                <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils' method='requiredParameters' >
                                    <parameter name="vf-module-topology-operation-input.vf-module-information.vf-module-id" value="$vf-module-topology-operation-input.vf-module-information.vf-module-id"/>
                                </execute>
                                <switch test="`$vf-module-topology-operation-input.vf-module-information.vf-module-id`">
                                    <outcome value=''>
                                        <return status='failure'>
                                            <parameter name='ack-final' value='Y'/>
                                            <parameter name="error-code" value="500" />
                                            <parameter name="error-message" value="network-request-input.network-input-parameters.name is a required input" />
                                        </return>
                                    </outcome>
                                </switch>
                                <switch test='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module_length`'>
                                    <outcome value=''>
                                        <return status='failure'>
                                            <parameter name='ack-final' value='Y'/>
                                            <parameter name="error-code" value="500" />
                                            <parameter name="error-message" value="vf-module-topology-operation-input.vf-module-request-input.vf-module-id not found in service-data" />
                                        </return>
                                    </outcome>
                                    <outcome value='Other'>
                                        <block atomic="true">
                                            <for index='nidx' start='0' end='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module_length`' >
                                                <switch test="`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$nidx].vf-module-id == $vf-module-topology-operation-input.vf-module-information.vf-module-id`">
                                                    <outcome value='true'>
                                                        <block atomic="true">
                                                            <set>
                                                                <parameter name='tmp.vidx' value='`$nidx`' />
                                                                <parameter name='ctx.vf-module-data.' value='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$nidx].vf-module-data.`' />
                                                            </set>
                                                        </block>
                                                    </outcome>
                                                </switch>
                                            </for>
                                            <switch test="`$tmp.vidx`">
                                                <outcome value=''>
                                                    <return status='failure'>
                                                        <parameter name='ack-final' value='Y'/>
                                                        <parameter name="error-code" value="500" />
                                                        <parameter name="error-message" value="vf-module-topology-operation-input.vf-module-request-input.vf-module-id not found in service-data" />
                                                    </return>
                                                </outcome>
                                            </switch>
                                        </block>
                                    </outcome>
                                </switch>
                                <switch test='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$tmp.vidx].vf-module-data.vf-module-level-oper-status.order-status`'>
                                    <outcome value='PendingDelete'>
                                        <block atomic="true"></block>
                                    </outcome>
                                    <outcome value='Other'>
                                        <return status='failure'>
                                            <parameter name='ack-final' value='Y'/>
                                            <parameter name="error-code" value="500" />
                                            <parameter name="error-message" value="`'vf-module is not in appropriate state for delete. Current state is ' + $service-data.vf-modules.vf-module[$tmp.nidx].vf-module-data.vf-module-level-oper-status.order-status`" />
                                        </return>
                                    </outcome>
                                </switch>
                            </block>
                        </outcome>
                        <outcome value='Other'>
                            <return status='failure'>
                                <parameter name='ack-final' value='Y'/>
                                <parameter name="error-code" value="500" />
                                <parameter name="error-message" value="request-information.request-action is required to be SOTN DeleteVPNNetworkInstance for svc-action=delete" />
                            </return>
                        </outcome>
                    </switch>
                </outcome>
                <outcome value='Other'>
                    <return status='failure'>
                        <parameter name='ack-final' value='Y'/>
                        <parameter name="error-code" value="500" />
                        <parameter name="error-message" value="`$vf-module-topology-operation-input.sdnc-request-header.svc-action + ' is not a valid svc-action'`" />
                    </return>
                </outcome>
            </switch>
        </block>
    </method>
</service-logic>