To allow for the widest possible array of data manipulation, Oomnitza's Jinja2 functionality also allows you to import libraries to perform even more complex functions.
For security reasons, Oomnitza limits this to the following libraries:
- re
- struct
- datetime
- calendar
- time
- collections
- bisect
- math
- random
- statistics
- hashlib
- hmac
- secrets
- json
- base64
- binhex
- binascii
- html
- xml
- urllib.parse
- uuid
See Python standard libraries.
Using the Libraries
These Libraries can be imported and utilized in your Jinja2 Commands using the following syntax:
{% set datetime = import('datetime') %}
This will provide you with an object that can be used in downstream functions in your Jinja2 Command. For example, using the datetime library, we can compare a datetime field with the current time and provide an output accordingly:
{% set datetime = import('datetime') %}{% set now = datetime.datetime.timestamp(datetime.datetime.utcnow()) %}{% if (0 + offboarding_date|int) > now %}{{"yes"}}{% else %}{{"no"}}{% endif %}
For any questions or assistance with setting up Jinja2 commands or using libraries, please reach out to support@oomnitza.com.
Comments
0 comments
Please sign in to leave a comment.