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>.

  • fn.list_to_string: Given a list as input, return the list as a string.

    Note the following in the output - refer to the example below:

    • strings in the list will be prefixed with a Unicode character u

    • the “[” and “]” as well as the commas between list items are included in the converted string

  • fn.list_items_to_string: Given a list as input (strings or integers), return each item as a string.

    Only simple lists are supported.

  • fn.list_items_to_int: Given a list of integers as input, return each item as a string.

    Only simple lists are supported.

    Only lists of integers are supported.

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

Example

Output

{{ fn.getMajorMinorVersion 10.5(4) }}

{{ fn.getMajorMinorVersion 11.5(1) SU1 }}

{{ fn.getMajorMinorVersion 11.5.3 }}
10.5

11.5

11.5
{"pwf": {
 "my_list": [1, null, 2,"test", 3, null]
 }
}


{{ fn.list_to_string pwf.my_list }}
"[1, None, 2, u'test', 3, None]"
{"pwf": {
 "my_list": [1, 2, "3", 4]
 }
}


{{ fn.list_items_to_string pwf.my_list }}
['1', '2', '3', '4']
{"pwf": {
 "my_list": [1, 2, "3", 4]
 }
}


{{ fn.list_items_to_int pwf.my_list }}
[1, 2, 3, 4]