Conversion Functions¶
- fn.pkid_to_bkey: Given a pkid, return the business key.
- fn.bkey_to_pkid: Given a business key, return the pkid Provide the data type as an argument.
- fn.from_business_key_format: Convert a field business key string format to a list
- fn.as_int: Given a string, return an integer.
- fn.as_string: Given an integer, return a string.
- fn.as_bool: Given strings “True”, “TRUE”, “T”, “t”, “1”, return True. Given strings “False”, “FALSE”, “F”, “f”, “0”, return False.
- fn.as_list: Given input, return it as a list. List input is returned as is.
- fn.int_to_hex: Return the hexadecimal value of an integer. Application example: for gateways that use hexadecimal values for port numbers.
- fn.hex_to_int: Return the integer value of a hexadecimal value. Application example: for gateways that use hexadecimal values for port numbers.
- fn.getMajorMinorVersion: Given a version in various formats, return a version of the format <major>.<minor>.
Examples:
Example | Output |
---|---|
macro: USA_pkid =
{{data.Countries.__pkid
iso_country_code:USA}}
{{fn.pkid_to_bkey macro.USA_pkid}}
|
"[u'United States of America',
u'USA', u'']"
|
macro: a_country_bkey =
{{data.Countries.__bkey
__pkid:macro.USA_pkid}}
{{fn.bkey_to_pkid macro.a_country_bkey,
data/Countries}}
|
"52d3eba8893d57373f842acb"
|
context data: {
"self": {
"bk": "[\"10.110.21.101\",
\"8443\",
\"hcs.CS-P.CS-NB.AAAGlobal\"]"
}
}
function: {{ fn.from_business_key_format self.bk }}
|
[
"10.110.21.101",
"8443",
"hcs.CS-P.CS-NB.AAAGlobal"
[
|
Example | Output |
---|---|
{{fn.as_int "1"}}
|
1
|
{{fn.as_string 12345}}
|
"12345"
|
{{fn.as_bool "T"}}
{{fn.as_bool "0"}}
|
true
false
|
{#fn.as_list foo bar#}
{#fn.as_list 'foo,bar'#}
{#fn.as_list ['foo','bar']#}
|
['foo bar']
['foo,bar']
['foo','bar']
|
{{fn.int_to_hex 255}}
|
ff
|
{{fn.hex_to_int ff}}
|
255
|
{{ fn.getMajorMinorVersion 10.5(4) }}
{{ fn.getMajorMinorVersion 11.5(1) SU1 }}
{{ fn.getMajorMinorVersion 11.5.3 }}
|
10.5
11.5
11.5
|