----------------------------------------------


Variables Used:
- portalApi.Uuid

-------------------------------------------------

{% func FromApiServiceTemplate(portalApi PortalAPI) %}
<?xml version="1.0" encoding="UTF-8"?>
<wsp:Policy xmlns:L7p="http://www.layer7tech.com/ws/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy">
  <wsp:All wsp:Usage="Required">
    <L7p:CommentAssertion>
      <L7p:Comment stringValue="------ Portal Created Fragment . Do not Modify ------"/>
    </L7p:CommentAssertion>
    <L7p:CommentAssertion>
      <L7p:Comment stringValue="------- Encass has a route in it. ------"/>
    </L7p:CommentAssertion>
    <L7p:SetVariable>
      <L7p:Base64Expression stringValue="ZmFsc2U="/>
      <L7p:VariableToSet stringValue="override_template_routing"/>
    </L7p:SetVariable>
    <L7p:Include>
      <L7p:PolicyGuid stringValue="812ed196-c315-4e92-b630-b5c64c5c043c"/>
      <L7p:PolicyName stringValue="Portal Service Preface"/>
    </L7p:Include>
    <L7p:Include>
      <L7p:PolicyGuid stringValue="{%s portalApi.Uuid %}"/>
    </L7p:Include>
    <L7p:CommentAssertion>
      <L7p:Comment stringValue="------ Portal Created Fragment . Do not Modify ------"/>
    </L7p:CommentAssertion>
    <L7p:CommentAssertion>
      <L7p:Comment stringValue="------ This routing path will be executed if using override template routing ------"/>
    </L7p:CommentAssertion>
    <wsp:OneOrMore wsp:Usage="Required">
      <L7p:ComparisonAssertion>
        <L7p:CaseSensitive booleanValue="false"/>
        <L7p:Expression1 stringValue="${override_template_routing}"/>
        <L7p:Expression2 stringValue="false"/>
        <L7p:Predicates predicates="included">
          <L7p:item binary="included">
            <L7p:CaseSensitive booleanValue="false"/>
            <L7p:RightValue stringValue="false"/>
          </L7p:item>
        </L7p:Predicates>
      </L7p:ComparisonAssertion>
      <wsp:All wsp:Usage="Required">
        <L7p:SetVariable>
          <L7p:Base64Expression stringValue="JHtyZXF1ZXN0Lmh0dHAudXJpfQ=="/>
          <L7p:VariableToSet stringValue="param.uri"/>
        </L7p:SetVariable>
        <L7p:Regex>
          <L7p:AutoTarget booleanValue="false"/>
          <L7p:OtherTargetMessageVariable stringValue="param.uri"/>
          <L7p:PatternContainsVariables booleanValue="true"/>
          <L7p:Regex stringValue="/${serviceUrl}"/>
          <L7p:RegexName stringValue="process uri"/>
          <L7p:Replace booleanValue="true"/>
          <L7p:Replacement stringValue=""/>
          <L7p:Target target="OTHER"/>
        </L7p:Regex>
        <wsp:OneOrMore wsp:Usage="Required">
          <wsp:All wsp:Usage="Required">
            <L7p:HttpRoutingAssertion>
              <L7p:FailOnErrorStatus booleanValue="false"/>
              <L7p:ProtectedServiceUrl stringValue="${apiLocation}${param.uri}${request.url.query}"/>
              <L7p:ProxyPassword stringValueNull="null"/>
              <L7p:ProxyUsername stringValueNull="null"/>
              <L7p:RequestHeaderRules httpPassthroughRuleSet="included">
                <L7p:Rules httpPassthroughRules="included">
                  <L7p:item httpPassthroughRule="included">
                    <L7p:Name stringValue="Cookie"/>
                  </L7p:item>
                  <L7p:item httpPassthroughRule="included">
                    <L7p:Name stringValue="SOAPAction"/>
                  </L7p:item>
                </L7p:Rules>
              </L7p:RequestHeaderRules>
              <L7p:RequestParamRules httpPassthroughRuleSet="included">
                <L7p:ForwardAll booleanValue="true"/>
                <L7p:Rules httpPassthroughRules="included"/>
              </L7p:RequestParamRules>
              <L7p:ResponseHeaderRules httpPassthroughRuleSet="included">
                <L7p:Rules httpPassthroughRules="included">
                  <L7p:item httpPassthroughRule="included">
                    <L7p:Name stringValue="Set-Cookie"/>
                  </L7p:item>
                </L7p:Rules>
              </L7p:ResponseHeaderRules>
              <L7p:SamlAssertionVersion intValue="2"/>
            </L7p:HttpRoutingAssertion>
            <L7p:SetVariable>
              <L7p:Base64Expression stringValue="JHtyZXNwb25zZS5odHRwLnN0YXR1c30="/>
              <L7p:VariableToSet stringValue="portal.analytics.response.code"/>
            </L7p:SetVariable>
          </wsp:All>
          <wsp:All wsp:Usage="Required">
            <L7p:SetVariable>
              <L7p:Base64Expression stringValue="JHtyZXNwb25zZS5odHRwLnN0YXR1c30="/>
              <L7p:VariableToSet stringValue="portal.analytics.response.code"/>
            </L7p:SetVariable>
            <L7p:SetVariable>
              <L7p:Base64Expression stringValue="VW5hYmxlIHRvIHJvdXRlIHRvIEFQSS4="/>
              <L7p:VariableToSet stringValue="errorMsg"/>
            </L7p:SetVariable>
            <wsp:OneOrMore wsp:Usage="Required">
              <L7p:ComparisonAssertion>
                <L7p:CaseSensitive booleanValue="false"/>
                <L7p:Expression1 stringValue="${portal.analytics.response.code}"/>
                <L7p:ExpressionIsVariable booleanValue="false"/>
                <L7p:Operator operatorNull="null"/>
                <L7p:Predicates predicates="included">
                  <L7p:item dataType="included">
                    <L7p:Type variableDataType="string"/>
                  </L7p:item>
                  <L7p:item stringLength="included">
                    <L7p:Max intValue="-1"/>
                    <L7p:Min intValue="1"/>
                  </L7p:item>
                </L7p:Predicates>
              </L7p:ComparisonAssertion>
              <L7p:SetVariable>
                <L7p:Base64Expression stringValue="NDA4"/>
                <L7p:VariableToSet stringValue="portal.analytics.response.code"/>
              </L7p:SetVariable>
            </wsp:OneOrMore>
            <L7p:FalseAssertion/>
          </wsp:All>
        </wsp:OneOrMore>
        <L7p:SetVariable>
          <L7p:Base64Expression stringValue="JHtyZXF1ZXN0LnJvdXRpbmdUb3RhbFRpbWV9"/>
          <L7p:VariableToSet stringValue="portal.analytics.routingTotalTime"/>
        </L7p:SetVariable>
        <L7p:ExportVariables>
          <L7p:ExportedVars stringArrayValue="included">
            <L7p:item stringValue="portal.analytics.response.code"/>
            <L7p:item stringValue="portal.analytics.routingTotalTime"/>
          </L7p:ExportedVars>
        </L7p:ExportVariables>
      </wsp:All>
    </wsp:OneOrMore>
  </wsp:All>
</wsp:Policy>
{% endfunc %}