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


Variables Used:
- portalApi.Name
- portalApi.UuidStripped
- portalApi.Uuid
- portalApi.ServiceId
- portalApi.SsgUrl
- portalApi.ApiEnabled
- portalApi.ModifyTs
- portalApi.CustomFields
- apiServiceXml
- apiFragmentXml
- isSoapAPI
- wsdl (empty string for REST)

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

{% func FromRestmamTemplate(portalApi PortalAPI, apiServiceXml string, apiFragmentXml string, isSoapApi string, wsdl string)  %}
<l7:Bundle xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
  <l7:References>
    <l7:Item xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
      <l7:Name>{%s portalApi.Name %}-fragment</l7:Name>
      <l7:Id>{%s portalApi.UuidStripped %}</l7:Id>
      <l7:Type>POLICY</l7:Type>
      <l7:Resource>
        <l7:Policy guid="{%s portalApi.Uuid %}" id="{%s portalApi.UuidStripped %}" version="0">
          <l7:PolicyDetail folderId="ddb84c6f397d7dbd3cca71d3043f019c" guid="{%s portalApi.Uuid %}" id="{%s portalApi.UuidStripped %}">
            <l7:Name>{%s portalApi.Name %}-fragment</l7:Name>
            <l7:PolicyType>Include</l7:PolicyType>
            <l7:Properties>
              <l7:Property key="revision">
                <l7:LongValue>1</l7:LongValue>
              </l7:Property>
              <l7:Property key="soap">
                <l7:BooleanValue>{%s isSoapApi %}</l7:BooleanValue>
              </l7:Property>
            </l7:Properties>
          </l7:PolicyDetail>
          <l7:Resources>
            <l7:ResourceSet tag="policy">
              <l7:Resource type="policy">{%s apiFragmentXml %}</l7:Resource>
            </l7:ResourceSet>
          </l7:Resources>
        </l7:Policy>
      </l7:Resource>
    </l7:Item>
    <l7:Item xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
      <l7:Name>{%s portalApi.Name %}</l7:Name>
      <l7:Id>{%s portalApi.ServiceId %}</l7:Id>
      <l7:Type>SERVICE</l7:Type>
      <l7:Resource>
        <l7:Service id="{%s portalApi.ServiceId %}" xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
          <l7:ServiceDetail folderId="ddb84c6f397d7dbd3cca71d3043f019c" id="{%s portalApi.ServiceId %}">
            <l7:Name>{%s portalApi.Name %}</l7:Name>
            <l7:Enabled>true</l7:Enabled>
            <l7:ServiceMappings>
              <l7:HttpMapping>
                <l7:UrlPattern>/{%s portalApi.SsgUrl %}</l7:UrlPattern>
                <l7:Verbs>
                  {% if isSoapApi == "true" %}
                    <l7:Verb>GET</l7:Verb>
                    <l7:Verb>POST</l7:Verb>
                  {% else %}
                    <l7:Verb>GET</l7:Verb>
                    <l7:Verb>POST</l7:Verb>
                    <l7:Verb>PUT</l7:Verb>
                    <l7:Verb>DELETE</l7:Verb>
                    <l7:Verb>OPTIONS</l7:Verb>
                    <l7:Verb>PATCH</l7:Verb>
                    <l7:Verb>HEAD</l7:Verb>
                  {% endif %}
                </l7:Verbs>
              </l7:HttpMapping>
            </l7:ServiceMappings>
            <l7:Properties>
              <l7:Property key="internal">
                <l7:BooleanValue>false</l7:BooleanValue>
              </l7:Property>
              <l7:Property key="soap">
                <l7:BooleanValue>{%s isSoapApi %}</l7:BooleanValue>
              </l7:Property>
              <l7:Property key="tracingEnabled">
                <l7:BooleanValue>false</l7:BooleanValue>
              </l7:Property>
              <l7:Property key="wssProcessingEnabled">
                <l7:BooleanValue>false</l7:BooleanValue>
              </l7:Property>
              <l7:Property key="portalID">
                <l7:StringValue>{%s portalApi.Uuid %}</l7:StringValue>
              </l7:Property>
              <l7:Property key="internal.portalAPIEnabled">
                <l7:StringValue>{%v portalApi.ApiEnabled %}</l7:StringValue>
              </l7:Property>
              <l7:Property key="portalModifyTS">
                <l7:StringValue>{%d portalApi.ModifyTs %}</l7:StringValue>
              </l7:Property>
              {% for _, customField := range portalApi.CustomFields %}
              <l7:Property key="{%s customField.Name %}" xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
                  <l7:StringValue>{%s customField.Value %}</l7:StringValue>
              </l7:Property>
              {% endfor %}
            </l7:Properties>
          </l7:ServiceDetail>
          <l7:Resources>
            <l7:ResourceSet tag="policy">
              <l7:Resource type="policy">{%s apiServiceXml %}</l7:Resource>
            </l7:ResourceSet>
            {% if isSoapApi == "true" %}
              <l7:ResourceSet tag="wsdl">
                <l7:Resource type="wsdl">{%s wsdl %}</l7:Resource>
              </l7:ResourceSet>
            {% endif %}
          </l7:Resources>
        </l7:Service>
      </l7:Resource>
    </l7:Item>
  </l7:References>
  <l7:Mappings>
    <l7:Mapping action="NewOrUpdate" srcId="{%s portalApi.UuidStripped %}" type="POLICY" xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management"/>
    <l7:Mapping action="NewOrUpdate" srcId="{%s portalApi.ServiceId %}" type="SERVICE" xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management"/>
  </l7:Mappings>
</l7:Bundle>
{% endfunc %}