|
| 1 | +--- |
| 2 | +title: Python SDK Templating |
| 3 | +--- |
| 4 | +Filters can be used when defining [computed attributes](https://docs.infrahub.app/guides/computed-attributes) or [Jinja2 Transforms](https://docs.infrahub.app/guides/jinja2-transform) within Infrahub. |
| 5 | + |
| 6 | +## Builtin Jinja2 filters |
| 7 | + |
| 8 | +The following filters are those that are [shipped with Jinja2](https://jinja.palletsprojects.com/en/stable/templates/#list-of-builtin-filters) and enabled within Infrahub. The trusted column indicates if the filter is allowed for use with Infrahub's computed attributes when the server is configured in strict mode. |
| 9 | + |
| 10 | +<!-- vale off --> |
| 11 | +| Name | Trusted | |
| 12 | +|----------|----------| |
| 13 | +| abs | ✅ | |
| 14 | +| attr | ❌ | |
| 15 | +| batch | ❌ | |
| 16 | +| capitalize | ✅ | |
| 17 | +| center | ✅ | |
| 18 | +| count | ✅ | |
| 19 | +| d | ✅ | |
| 20 | +| default | ✅ | |
| 21 | +| dictsort | ❌ | |
| 22 | +| e | ✅ | |
| 23 | +| escape | ✅ | |
| 24 | +| filesizeformat | ✅ | |
| 25 | +| first | ✅ | |
| 26 | +| float | ✅ | |
| 27 | +| forceescape | ✅ | |
| 28 | +| format | ✅ | |
| 29 | +| groupby | ❌ | |
| 30 | +| indent | ✅ | |
| 31 | +| int | ✅ | |
| 32 | +| items | ❌ | |
| 33 | +| join | ✅ | |
| 34 | +| last | ✅ | |
| 35 | +| length | ✅ | |
| 36 | +| list | ✅ | |
| 37 | +| lower | ✅ | |
| 38 | +| map | ❌ | |
| 39 | +| max | ✅ | |
| 40 | +| min | ✅ | |
| 41 | +| pprint | ❌ | |
| 42 | +| random | ❌ | |
| 43 | +| reject | ❌ | |
| 44 | +| rejectattr | ❌ | |
| 45 | +| replace | ✅ | |
| 46 | +| reverse | ✅ | |
| 47 | +| round | ✅ | |
| 48 | +| safe | ❌ | |
| 49 | +| select | ❌ | |
| 50 | +| selectattr | ❌ | |
| 51 | +| slice | ✅ | |
| 52 | +| sort | ❌ | |
| 53 | +| string | ✅ | |
| 54 | +| striptags | ✅ | |
| 55 | +| sum | ✅ | |
| 56 | +| title | ✅ | |
| 57 | +| tojson | ❌ | |
| 58 | +| trim | ✅ | |
| 59 | +| truncate | ✅ | |
| 60 | +| unique | ❌ | |
| 61 | +| upper | ✅ | |
| 62 | +| urlencode | ✅ | |
| 63 | +| urlize | ❌ | |
| 64 | +| wordcount | ✅ | |
| 65 | +| wordwrap | ✅ | |
| 66 | +| xmlattr | ❌ | |
| 67 | +<!-- vale on --> |
| 68 | + |
| 69 | +## Netutils filters |
| 70 | + |
| 71 | +The following Jinja2 filters from <a href="https://netutils.readthedocs.io">Netutils</a> are included within Infrahub. |
| 72 | +<!-- vale off --> |
| 73 | +| Name | Trusted | |
| 74 | +|----------|----------| |
| 75 | +| abbreviated_interface_name | ✅ | |
| 76 | +| abbreviated_interface_name_list | ✅ | |
| 77 | +| asn_to_int | ✅ | |
| 78 | +| bits_to_name | ✅ | |
| 79 | +| bytes_to_name | ✅ | |
| 80 | +| canonical_interface_name | ✅ | |
| 81 | +| canonical_interface_name_list | ✅ | |
| 82 | +| cidr_to_netmask | ✅ | |
| 83 | +| cidr_to_netmaskv6 | ✅ | |
| 84 | +| clean_config | ✅ | |
| 85 | +| compare_version_loose | ✅ | |
| 86 | +| compare_version_strict | ✅ | |
| 87 | +| config_compliance | ✅ | |
| 88 | +| config_section_not_parsed | ✅ | |
| 89 | +| delimiter_change | ✅ | |
| 90 | +| diff_network_config | ✅ | |
| 91 | +| feature_compliance | ✅ | |
| 92 | +| find_unordered_cfg_lines | ✅ | |
| 93 | +| fqdn_to_ip | ❌ | |
| 94 | +| get_all_host | ❌ | |
| 95 | +| get_broadcast_address | ✅ | |
| 96 | +| get_first_usable | ✅ | |
| 97 | +| get_ips_sorted | ✅ | |
| 98 | +| get_nist_urls | ✅ | |
| 99 | +| get_nist_vendor_platform_urls | ✅ | |
| 100 | +| get_oui | ✅ | |
| 101 | +| get_peer_ip | ✅ | |
| 102 | +| get_range_ips | ✅ | |
| 103 | +| get_upgrade_path | ✅ | |
| 104 | +| get_usable_range | ✅ | |
| 105 | +| hash_data | ✅ | |
| 106 | +| int_to_asdot | ✅ | |
| 107 | +| interface_range_compress | ✅ | |
| 108 | +| interface_range_expansion | ✅ | |
| 109 | +| ip_addition | ✅ | |
| 110 | +| ip_subtract | ✅ | |
| 111 | +| ip_to_bin | ✅ | |
| 112 | +| ip_to_hex | ✅ | |
| 113 | +| ipaddress_address | ✅ | |
| 114 | +| ipaddress_interface | ✅ | |
| 115 | +| ipaddress_network | ✅ | |
| 116 | +| is_classful | ✅ | |
| 117 | +| is_fqdn_resolvable | ❌ | |
| 118 | +| is_ip | ✅ | |
| 119 | +| is_ip_range | ✅ | |
| 120 | +| is_ip_within | ✅ | |
| 121 | +| is_netmask | ✅ | |
| 122 | +| is_network | ✅ | |
| 123 | +| is_reversible_wildcardmask | ✅ | |
| 124 | +| is_valid_mac | ✅ | |
| 125 | +| longest_prefix_match | ✅ | |
| 126 | +| mac_normalize | ✅ | |
| 127 | +| mac_to_format | ✅ | |
| 128 | +| mac_to_int | ✅ | |
| 129 | +| mac_type | ✅ | |
| 130 | +| name_to_bits | ✅ | |
| 131 | +| name_to_bytes | ✅ | |
| 132 | +| name_to_name | ✅ | |
| 133 | +| netmask_to_cidr | ✅ | |
| 134 | +| netmask_to_wildcardmask | ✅ | |
| 135 | +| normalise_delimiter_caret_c | ✅ | |
| 136 | +| paloalto_panos_brace_to_set | ✅ | |
| 137 | +| paloalto_panos_clean_newlines | ✅ | |
| 138 | +| regex_findall | ❌ | |
| 139 | +| regex_match | ❌ | |
| 140 | +| regex_search | ❌ | |
| 141 | +| regex_split | ❌ | |
| 142 | +| regex_sub | ❌ | |
| 143 | +| sanitize_config | ✅ | |
| 144 | +| section_config | ✅ | |
| 145 | +| sort_interface_list | ✅ | |
| 146 | +| split_interface | ✅ | |
| 147 | +| uptime_seconds_to_string | ✅ | |
| 148 | +| uptime_string_to_seconds | ✅ | |
| 149 | +| version_metadata | ✅ | |
| 150 | +| vlanconfig_to_list | ✅ | |
| 151 | +| vlanlist_to_config | ✅ | |
| 152 | +| wildcardmask_to_netmask | ✅ | |
| 153 | +<!-- vale on --> |
0 commit comments