Zero, Unset, Boolean, Drop, Null and Exists Functions#
Function |
Description |
Example |
Output or Result |
---|---|---|---|
fn.zero |
Return a zero value. |
{{fn.zero}}
|
0
|
fn.unset |
Return an empty string. |
{{fn.unset}}
|
''
|
fn.true |
Return a boolean True. |
{{fn.true}}
|
true
|
fn.false |
Return a boolean False. |
{{fn.false}}
|
false
|
Given input context:
{"input": {"field1": {"key1": "value1"}}}
{"input": {"field1": None}}
{"input": {"field1": ""}}
Function |
Description |
Example |
Input and Result |
---|---|---|---|
fn.is_none_or_empty |
Return a boolean if the argument is None or an empty string |
{{fn.is_none_or_empty
input.field1}}
|
input 1. false
input 2. true
input 3. true
|
Note
If fn.is_none_or_empty
is used along with inline macro queries that have where/option clauses,
the macro should be split into 2 parts.
Examples:
Instead of:
(( fn.is_non_or_empty data.User.username | username:input.username == fn.true )) <> <>
write as follows:
USERNAME= {{ data.User.username | username:input.username }}
(( fn.is_non_or_empty pwf.USERNAME == fn.true )) <> <>
2. Instead of:
::
{ "set_var_name": "user_role",
"set_var_value": "(( fn.is_none_or_empty data.User.role | username:pwf.username | direction:down == false ))<{{ data.User.role | username:pwf.username || direction:down }}><{{ macro.LOCAL_SELFSERVICE_ROLE }}>"
},
write as follows:
::
{ "set_var_name": "data_user_role",
"set_var_value": "{{ data.User.role | username:pwf.username | direction:down }}"
},
{ "set_var_name": "user_role",
"set_var_value": "(( fn.is_none_or_empty pwf.data_user_role == false ))<{{ pwf.data_user_role }}><{{ macro.LOCAL_SELFSERVICE_ROLE }}>"
},
Given input context:
{
"input": {
"test": null
}
}
Function |
Description |
Example |
Output or Result |
---|---|---|---|
fn.null |
Returns Null. Useful in comparison tests. |
(( input.test ==
fn.null ))
|
true
|
Function |
Description |
Example |
Output or Result |
---|---|---|---|
fn.drop |
Removes the attribute from CFT |
{'name':
'{{fn.drop}}'}
|
Attribute as in existing data |
fn.force_null |
Attribute has Null value |
{'name':
'{{fn.force_null}}'}
|
{'name': None}
|
Useful in Configuration Templates (CFT):
Function fn.drop
in a CFT will drop a value from the input data
when it is processed through a CFT. Input data without the dropped field is then
overlaid onto the existing model data by the workflow code.
The final payload data for the value will thus remain the same as in the
existing model data.
Example of fn.drop
in an if-then-else test from a CFT of a workflow:
"ldapDirectoryName": "(( input.cucm_user_ldapDirectoryName != '' ))
<{{ input.cucm_user_ldapDirectoryName }}>
<{{ fn.drop }}"
Function |
Description |
Example |
Output or Result |
---|---|---|---|
fn.drop_from_payload |
Removes the attribute from payload |
{'name':
'{{fn.drop_from_payload}}'}
|
Attribute “blank” |
Useful in Configuration Templates (CFT):
Function fn.drop_from_payload forces a field to not be present in the final payload data. Used in a CFT, it will drop a value from the existing model data after the input data is overlaid onto the existing model data. The value is then not present, i.e. “blanked”.
Example of fn.drop_from_payload
in a CFT so that attributes
are blanked:
{
"meta": {},
"resources": [
{
"data": {
"name": "ConvertCUCUserCFT",
"target_model_type": "device/cuc/User",
"template": {
"LdapType": "0",
"LdapCcmUserId": "{{ fn.drop_from_payload }}",
"LdapCcmPkid": "{{ fn.drop_from_payload }}"
}
},
"meta": {
"model_type": "data/ConfigurationTemplate",
"system_resource": true,
"tags": [
"convertusertype"
]
}
}
]
}
Given input context:
{"input": {"field1": {"key1": "value1"}}}
{"input": {"field1": {"key1": null}}}
{"input": {"field1": ""}}
Function |
Description |
Example |
Input and Result |
---|---|---|---|
fn.exists |
Return a boolean true if the argument is exits and has a non-null value. |
{{ fn.exists
input.field1.key1 }}
|
input 1. true
input 2. false
input 3. false
|
fn.exists |
If the argument does not exist, it is interpreted as a string - which is interpretable, so the function returns true. |
{{ fn.exists
field.key }}
|
input 1, 2, 3 true
|