{%- if filetype_loop == 0 %}Site,Hostname,Instance UUID,Instance Tenant ID,Deployment Pending,Instance Version,Access Point Manager Interface IP,Associated WLC IP,Boot Date Time,Collection Interval,Collection Interval Value,Collection Interval Status,Description,Support Level,Family,Interface Count,Inventory Status,Last Update,Last Update Time,Line Card Count,Line Card ID,MAC Address,Managed At Least Once,IP Address,State,Memory Size,Platform ID,Reachability Status,Reachability Failure Reason,Role,Role Source,Serial Number,Series,SNMP Contact,SNMP Location,Software Type,Software Version,Tag Count,Tunnel UDP Port,Type,Uptime
{%-     for item in siteMembers if item.response %}
{%-         for member in item.response %}
{{ site }},{{ member.hostname }},{{ member.instanceUuid }},{{ member.instanceTenantId }},{{ member.deployPending }},{{ member.instanceVersion }},{{ member.apManagerInterfaceIp }},{{ member.associatedWlcIp }},{{ member.bootDateTime }},{{ member.collectionInterval }},{{ member.collectionIntervalValue }},{{ member.collectionStatus }},{{ member.description | replace(","," ")}},{{ member.deviceSupportLevel }},{{ member.family }},{{ member.interfaceCount }},{{ member.inventoryStatusDetail }},{{ member.lastUpdated }},{{ member.lastUpdateTime }},{{ member.lineCardCount }},{{ member.lineCardId }},{{ member.macAddress }},{{ member.managedAtleastOnce }},{{ member.managementIpAddress }},{{ member.managementState }},{{ member.memorySize }},{{ member.platformId }},{{ member.reachabilityStatus }},{{ member.reachabilityFailureReason }},{{ member.role }},{{ member.roleSource }},{{ member.serialNumber }},{{ member.series }},{{ member.snmpContact }},{{ member.snmpLocation }},{{ member.softwareType }},{{ member.softwareVersion }},{{ member.tagCount }},{{ member.tunnelUdpPort }},{{ member.type }},{{ member.upTime }} {{ member.uptimeSeconds }}
{%-         endfor %}
{%-    endfor %}
{%- else %}
{%-     if filetype_loop == 1 %}
# Site Member
| Site | Hostname | Instance UUID | Instance Tenant ID | Deployment Pending | Instance Version | Access Point Manager Interface IP | Associated WLC IP | Boot Date Time | Collection Interval | Collection Interval Value | Collection Interval Status | Description | Support Level | Family | Interface Count | Inventory Status | Last Update | Last Update Time | Line Card Count | Line Card ID | MAC Address | Managed At Least Once | IP Address | State | Memory Size | Platform ID | Reachability Status | Reachability Failure Reason | Role | Role Source | Serial Number | Series | SNMP Contact | SNMP Location | Software Type | Software Version | Tag Count | Tunnel UDP Port | Type | Uptime |
| ---- | -------- | ------------- | ------------------ | ------------------ | ---------------- | --------------------------------- | ----------------- | -------------- | ------------------- | ------------------------- | -------------------------- | ----------- | ------------- | ------ | --------------- | ---------------- | ----------- | ---------------- | --------------- | ------------ | ----------- | --------------------- | ---------- | ----- | ----------- | ----------- | ------------------- | --------------------------- | ---- | ----------- | ------------- | ------ | ------------ | ------------- | ------------- | ---------------- | --------- | --------------- | ---- | ------ |
{%-         for item in siteMembers if item.response %}
{%-             for member in item.response %}
| {{ site }} | {{ member.hostname }} | {{ member.instanceUuid }} | {{ member.instanceTenantId }} | {{ member.deployPending }} | {{ member.instanceVersion }} | {{ member.apManagerInterfaceIp }} | {{ member.associatedWlcIp }} | {{ member.bootDateTime }} | {{ member.collectionInterval }} | {{ member.collectionIntervalValue }} | {{ member.collectionStatus }} | {{ member.description }} | {{ member.deviceSupportLevel }} | {{ member.family }} | {{ member.interfaceCount }} | {{ member.inventoryStatusDetail }} | {{ member.lastUpdated }} | {{ member.lastUpdateTime }} | {{ member.lineCardCount }} | {{ member.lineCardId }} | {{ member.macAddress }} | {{ member.managedAtleastOnce }} | {{ member.managementIpAddress }} | {{ member.managementState }} | {{ member.memorySize }} | {{ member.platformId }} | {{ member.reachabilityStatus }} | {{ member.reachabilityFailureReason }} | {{ member.role }} | {{ member.roleSource }} | {{ member.serialNumber }} | {{ member.series }} | {{ member.snmpContact }} | {{ member.snmpLocation }} | {{ member.softwareType }} | {{ member.softwareVersion }} | {{ member.tagCount }} | {{ member.tunnelUdpPort }} | {{ member.type }} | {{ member.upTime }} {{ member.uptimeSeconds }} |
{%-             endfor %}
{%-         endfor %}
{%-     else %}
{%-         if filetype_loop == 2 %}
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.0.0/js/dataTables.buttons.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.0.0/js/buttons.html5.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.0.0/js/buttons.print.min.js"></script>
    <script src="https://cdn.datatables.net/colreorder/1.5.4/js/dataTables.colReorder.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.0.0/js/buttons.colVis.min.js"></script>
    <script src="https://cdn.datatables.net/keytable/2.6.4/js/dataTables.keyTable.min.js"></script>
    <script src="https://cdn.datatables.net/select/1.3.3/js/dataTables.select.min.js"></script>
    <script src="https://cdn.datatables.net/fixedheader/3.1.9/js/dataTables.fixedHeader.min.js"></script>
    <link rel="stylesheet" href="https://cdn.datatables.net/fixedheader/3.1.9/css/fixedHeader.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/select/1.3.3/css/select.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/keytable/2.6.4/css/keyTable.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.min.css">
</head>
<body>
<h1>DNAC Site Member</h1>
<table id = "member">
  <thead>
    <tr>
      <th>Site</th>
      <th>Hostname</th>
      <th>Instance UUID</th>
      <th>Instance Tenant ID</th>
      <th>Deployment Pending</th>
      <th>Instance Version</th>
      <th>Access Point Manager Interface IP</th>
      <th>Associated WLC IP</th>
      <th>Boot Date Time</th>
      <th>Collection Interval</th>
      <th>Collection Interval Value</th>
      <th>Collection Interval Status</th>
      <th>Description</th>
      <th>Support Level</th>
      <th>Family</th>
      <th>Interface Count</th>
      <th>Inventory Status</th>
      <th>Last Update</th>
      <th>Last Update Time</th>
      <th>Line Card Count</th>
      <th>Line Card ID</th>
      <th>MAC Address</th>
      <th>Managed At Least Once</th>
      <th>IP Address</th>
      <th>State</th>
      <th>Memory Size</th>
      <th>Platform ID</th>
      <th>Reachability Status</th>
      <th>Reachability Failure Reason</th>
      <th>Role</th>
      <th>Role Source</th>
      <th>Serial Number</th>
      <th>Series</th>
      <th>SNMP Contact</th>
      <th>SNMP Location</th>
      <th>Software Type</th>
      <th>Software Version</th>
      <th>Tag Count</th>
      <th>Tunnel UDP Port</th>
      <th>Type</th>
      <th>Uptime</th>
    </tr>
  </thead>
  <tbody>
{%-             for item in siteMembers if item.response %}
{%-                 for member in item.response %}
<tr>
    <td>{{ site }}</td>
    <td>{{ member.hostname }}</td>
    <td>{{ member.instanceUuid }}</td>
    <td>{{ member.instanceTenantId }}</td>
    <td>{{ member.deployPending }}</td>
    <td>{{ member.instanceVersion }}</td>
    <td>{{ member.apManagerInterfaceIp }}</td>
    <td>{{ member.associatedWlcIp }}</td>
    <td>{{ member.bootDateTime }}</td>
    <td>{{ member.collectionInterval }}</td>
    <td>{{ member.collectionIntervalValue }}</td>
    <td>{{ member.collectionStatus }}</td>
    <td>{{ member.description }}</td>
    <td>{{ member.deviceSupportLevel }}</td>
    <td>{{ member.family }}</td>
    <td>{{ member.interfaceCount }}</td>
    <td>{{ member.inventoryStatusDetail }}</td>
    <td>{{ member.lastUpdated }}</td>
    <td>{{ member.lastUpdateTime }}</td>
    <td>{{ member.lineCardCount }}</td>
    <td>{{ member.lineCardId }}</td>
    <td>{{ member.macAddress }}</td>
    <td>{{ member.managedAtleastOnce }}</td>
    <td>{{ member.managementIpAddress }}</td>
    <td>{{ member.managementState }}</td>
    <td>{{ member.memorySize }}</td>
    <td>{{ member.platformId }}</td>
    <td>{{ member.reachabilityStatus }}</td>
    <td>{{ member.reachabilityFailureReason }}</td>
    <td>{{ member.role }}</td>
    <td>{{ member.roleSource }}</td>
    <td>{{ member.serialNumber }}</td>
    <td>{{ member.series }}</td>
    <td>{{ member.snmpContact }}</td>
    <td>{{ member.snmpLocation }}</td>
    <td>{{ member.softwareType }}</td>
    <td>{{ member.softwareVersion }}</td>
    <td>{{ member.tagCount }}</td>
    <td>{{ member.tunnelUdpPort }}</td>
    <td>{{ member.type }}</td>
    <td>{{ member.upTime }} {{ member.uptimeSeconds }}</td>
  </tr>
{%-                 endfor %}
{%-             endfor %}
  </tbody>
</table>
<script type = "text/javascript">
  $(document).ready(function(){
    $('#member thead tr')
    .clone(true)
    .addClass('filters')
    .appendTo('#member thead');

    var table = $('#member').DataTable({
        keys: true,
        dom: 'Bfrtip',
        lengthMenu: [
            [ 10, 25, 50, -1 ],
            [ '10 rows', '25 rows', '50 rows', 'Show all' ]
        ],
        buttons: [
        'pageLength','colvis','copy', 'csv', 'excel', 'pdf', 'print'
        ],
        colReorder: true,
        select: true,            
        orderCellsTop: true,
        fixedHeader: true,
        initComplete: function () {
        var api = this.api();

        // For each column
        api
            .columns()
            .eq(0)
            .each(function (colIdx) {
                // Set the header cell to contain the input element
                var cell = $('.filters th').eq(
                    $(api.column(colIdx).header()).index()
                );
                var title = $(cell).text();
                $(cell).html('<input type="text" placeholder="' + title + '" />');

                // On every keypress in this input
                $(
                    'input',
                    $('.filters th').eq($(api.column(colIdx).header()).index())
                )
                    .off('keyup change')
                    .on('keyup change', function (e) {
                        e.stopPropagation();

                        // Get the search value
                        $(this).attr('title', $(this).val());
                        var regexr = '({search})'; //$(this).parents('th').find('select').val();

                        var cursorPosition = this.selectionStart;
                        // Search the column for that value
                        api
                            .column(colIdx)
                            .search(
                                this.value != ''
                                    ? regexr.replace('{search}', '(((' + this.value + ')))')
                                    : '',
                                this.value != '',
                                this.value == ''
                            )
                            .draw();

                        $(this)
                            .focus()[0]
                            .setSelectionRange(cursorPosition, cursorPosition);
                    });
            });
    },
});
});        
</script>
</body></html>
{%-         else %}
# {{ site }}
## Site Members
{%-             for item in siteMembers if item.response %}
{%-                 for member in item.response %}
### {{ member.hostname }}
#### UUID: {{ member.instanceUuid }}
#### Tenant ID: {{ member.instanceTenantId }}
#### Deployment Pending: {{ member.deployPending }}
#### Instance Version: {{ member.instanceVersion }}
#### Access Point Manager Interface IP: {{ member.apManagerInterfaceIp }}
#### Associated WLC IP: {{ member.associatedWlcIp }}
#### Boot Date Time: {{ member.bootDateTime }}
#### Collection
##### {{ member.collectionInterval }}
##### {{ member.collectionIntervalValue }}
##### {{ member.collectionStatus }}
#### Description: {{ member.description }}
#### Support Level: {{ member.deviceSupportLevel }}
#### Family: {{ member.family }}
#### Interface Count: {{ member.interfaceCount }}
#### Inventory Status: {{ member.inventoryStatusDetail }}
#### Last Update: {{ member.lastUpdated }}
#### Last Update Time: {{ member.lastUpdateTime }}
#### Line Card Count: {{ member.lineCardCount }}
#### Line Card ID: {{ member.lineCardId }}
#### MAC Address: {{ member.macAddress }}
#### Mamagement
##### Managed At Least Once: {{ member.managedAtleastOnce }}
##### IP Address: {{ member.managementIpAddress }}
##### State: {{ member.managementState }}
#### Memory Size: {{ member.memorySize }}
#### Platform ID: {{ member.platformId }}
#### Reachability
##### {{ member.reachabilityStatus }}
##### Failure Reason: {{ member.reachabilityFailureReason }}
#### Role: {{ member.role }}
#### Role Source: {{ member.roleSource }}
#### Serial Number: {{ member.serialNumber }}
#### Series: {{ member.series }}
#### SNMP
##### Contact: {{ member.snmpContact }}
##### Location: {{ member.snmpLocation }}
#### Software
##### Type: {{ member.softwareType }}
##### Version: {{ member.softwareVersion }}
#### Tag Count: {{ member.tagCount }}
#### Tunnel UDP Port: {{ member.tunnelUdpPort }}
#### Type: {{ member.type }}
#### Uptime: {{ member.upTime }} {{ member.uptimeSeconds }}
{%-                  endfor %}
{%-             endfor %}
{%-         endif %}
{%-     endif %}
{%- endif %}