Built-in functions
str() to transform a number to a string.
str($parameters.order)
int() to transform a string into an integer.
int($parameters.priority)
str()
str() function transforms the input argument to a string value.
-
string -
number -
TCP-port -
boolean -
IP address
-
The
"set-" + str(10)function returns"set-10". -
The
str(10)function returns10. -
The
str(1.1.1.1)function returns1.1.1.1. -
The
str(T rue)function returns"T rue". -
The
str(ADM)function returns"mas".
int()
int() function takes a string, number, IP address, or tcpport as an argument and returns an integer.
-
The
int("10")function returns10. -
The
int(10)function returns10. -
The
int(ip('0.0.4.1'))function returns1025.
bool()
bool() function takes any type as an argument. If the argument value is false, empty, or absent, this function returns false.
true.
-
The
bool(true)function returnstrue. -
The
bool(false)function returnsfalse. -
The
bool($parameters.a)function returnsfalseif the$parameters.aisfalse, empty, or absent.
len()
len() function takes a string or a list as an argument, and returns the number of characters in a string or the number of items in a list.
items: ["123", "abc", "xyz"]
len($substitutions.items) function returns 3
len("NetScaler ADM") function returns 10.
$parameters.vips has values ['1.1.1.1', '1.1.1.2', '1.1.1.3'], the len($parameters.vips) function returns 3.
min()
min() function takes either a list or a series of numbers or tcp-ports as arguments, and returns the smallest item.
-
The
min(80, 100, 1000)function returns80. -
The
min(-20, 100, 400)function returns-20. -
The
min(-80, -20, -10)function returns-80. -
The
min(0, 100, -400)function returns-400.
-
Support
$parameters.portsis a list oftcp-portsand has values:[80, 81, 8080].Themin($parameters.ports)function returns80.
max()
max() function takes either a list or a series of numbers or tcp-ports as arguments, and returns the largest item.
-
The
max(80, 100, 1000)function returns1000. -
The
max(-20, 100, 400)function returns400. -
The
max(-80, -20, -10)function returns-10. -
The
max(0, 100, -400)function returns100.
-
Support
$parameters.portsis list oftcp-portsand has values:[80, 81, 8080].Themax($parameters.ports)function returns8080.
bin()
bin() function takes a number as an argument, and returns a string that represents the number in binary format.
bin(100) function returns 0b1100100.
oct()
oct() function takes a number as an argument, and returns a string that represents the number in octal format.
oct(100) function returns 0144.
hex()
hex() function takes a number as an argument, and returns a lowercase string that represents the number in hexadecimal format.
hex(100) function returns 0x64.
lower()
lower() function takes a string as an argument and returns the same string in the lowercase.
lower("ADM") function returns adm.
upper()
upper() function takes a string as an argument and returns the same string in uppercase.
upper("NetScaler ADM") function returns NetScaler ADM.
sum()
sum() function takes a list of numbers or tcpports as arguments and returns the sum of the numbers in the list.
list-of-numbers = [11, 22, 55]
sum($substitutions.list-of-numbers) function returns 88.
$parameters.ports is [80, 81, 82], the sum($parameters.ports) function returns 243.
pow()
pow() function takes two numbers as arguments and returns a number that represents the first argument raised to the power of the second one.
pow(3,2) function returns 9.
ip()
ip() function takes an integer, string, or an IP address as an argument and returns the IP address based on the input value.
-
Specify an IP address in the
ipfunction:Theip(3.1.1.1)function returns3.1.1.1. -
Specify a string in the
ipfunction:Theip('2.1.1.1')function returns2.1.1.1 -
Specify an integer in the
ipfunction:-
The
ip(12)function returns0.0.0.12. -
When you specify an integer as string in the
ipfunction, it returns an equivalent IP address of the input.Theip('1025')function returns0.0.4.1.
This function also supports the integer addition and subtraction operations and returns a resultant IP address.-
Addition: The
ip(1025) + ip(12)function returns0.0.4.13. -
Subtraction: The
ip('1025') - ip(12)function returns0.0.3.245. -
Combine addition and subtraction: The
ip('1.1.1.1') + ip('1.1.1.1') – ip(2)returns2.2.2.0.
-
base64.encode()
base64.encode() function takes a string argument and returns the base64 encoded string.
base64.encode("abcd") function returns YWJjZA==.
base64.decode()
base64.decode function takes a base64 encoded string as an argument and returns the decoded string.
base64.decode("YWJjZA==") function returns abcd.
exists()
exists() function takes an argument of any type and returns a boolean. The return value is True if the input has any value. The return value is False If the input argument does not have a value (that is, no value).
$parameters.monitor is an optional parameter. If you provide a value to this parameter when creating a configuration pack, exist the ($parameters.monitor) function returns True.
False.
filter()
filter() function takes two arguments.
True when passed to the substitution function in the first argument.
x(a): $a != 81
81. Otherwise, it returns False.
$parameters.ports is [81, 80, 81, 89].
filter($substitutions.x, $parameters.ports) returns [80, 89] by removing all occurrences of 81 from the list.
if-then-else()
if-then-else() takes three arguments.
True, the function returns the value of the expression provided as argument 2.
no.
if-then-else($parameters.servicetype == HTTP, 80, 443) function returns 80 if $parameters.servicetype has value HTTP. Otherwise, the function returns 443.
if-then-else($parameters.servicetype == HTTP, $parameters.hport, $parameters.sport) function returns the value of $parameters.hport if $parameters.servicetype has value HTTP.
$parameters.sport.
if-then-else($parameters.servicetype == HTTP, 80) returns 80 if $parameters.servicetype has value HTTP.
join()
join() function takes two arguments:
tcp-ports, strings, or IP addresses
-
$parameters.portsis[81, 82, 83].-
With delimiter argument:The
join($parameters.ports, '-')function returns81-82-83. -
Without delimiter argument:The
join($parameters.ports)function returns818283.
-
split()
split() function splits an input string into multiple lists depending on the specified separators. If no or blank ('') separator is specified, this function considers space as a separator and splits the string into lists.
-
The
split('Example_string_split', 's')function returns['Example_','tring_','plit']. -
The
split('Example string split')function returns['Example','string','split']. -
The
split('Example string split', '')function returns['Example','string','split']. -
The
split('Example string')function returns['Example','string'].This function considers continuous spaces as one space.
map()
map() function takes two arguments;
map() function (argument one) to the corresponding element in argument two.
-
Built-in functions that take one argument:
base64.encode, base64.decode, bin, bool, exists, hex, int, ip, len, lower, upper, oct, quotewrap, str, trim, upper, url.encode, url.decode -
Substitution functions that take at least one argument.
[81, 82, 83].
-
Map using a built-in function, strThe
map(str, $parameters.nums)function returns["81", "82", "83"]The result of the map function is the list of strings where each element is string is computed by applying the str function on the corresponding element in the input list ($parameters.nums). -
Map using a substitution function
-
Substitutions:
add-10(port): $port + 10 -
Expression:The
map($substitutions.add-10, $parameters.nums)function returns a list of numbers:[ 91, 92, 93 ]
-
$substitutions.add-10 on the corresponding element in the input list ($parameters.nums).
quotewrap()
quotewrap() function takes a string as an argument and returns a string after adding a double quote character before and after the input value.
quotewrap("ADM") function returns "mas"
replace()
replace() function takes three arguments:
-
The
replace('abcdef', 'def', 'xyz')function returnsabcxyz.All occurrences ofdefare replaced withxyz. -
replace('abcdefabc', 'def')returnsabcabc.As there is no third argument,defis removed from the resulting string.
$parameters.spl_chars = ['@', '#', '!', '%']
replace('An#example@to%replace!characters', $parameters.spl_chars, '_') function returns An_example_to_replace_characters.
_) instead of characters specified in the $parameters.spl_chars list.
trim()
trim() function returns a string where the leading and trailing whitespaces are stripped from the input string.
trim(' abc ') function returns abc.
truncate()
truncate() function takes two arguments:
truncate('NetScaler ADM', 6) returns Citrix.
distinct()
distinct() function extracts unique items from a list input.
$parameters.input_list is ['ADM', 'ADC', 'VPX', 'ADC', 'ADM', 'CPX'], the distinct($parameters.input_list) function returns ['ADM', 'ADC', 'VPX', 'CPX'].
url.encode()
url.encode() function returns a string where characters are transformed using the ASCII character set according to RFC 3986.
url.encode("a/b/c") function returns a%2Fb%2Fc.
url.decode()
url.decode() function returns a string where the URL encoded argument is decoded in to a regular string according to RFC 3986.
url.decode("a%2Fb%2Fc") function returns a/b/c.
is-ipv4()
is-ipv4() function takes an IP address as an argument and returns the boolean True if the IP address is of the IPv4 format.
is-ipv4(10.10.10.10) function returns True
is-ipv6()
is-ipv6() function takes an IP address as an argument and returns the boolean True if the IP address is of the IPv6 format.
is-ipv6(2001:DB8::) function returns True
startswith()
startswith() function determines whether a string begins with a given prefix. This function requires two mandatory string arguments.
startswith(str, sub_str)
True when the string (str) starts with the substring (sub_str).
-
The
startswith('Citrix', 'Ci')function returnsTrue. -
The
startswith('Citrix', 'iC')function returnsFalse -
The
startswith('Citrix', 'Ab')function returnsFalse
endswith()
endswith() function determines whether a string ends with a given suffix. This function requires two mandatory string arguments.
endswith(str, sub_str)
True when the string (str) ends with the substring (sub_str).
-
The
endswith('Citrix', 'ix')function returnsTrue. -
The
endswith('Citrix', 'Ix')function returnsFalse. -
The
endswith('Citrix', 'ab')function returnsFalse.
contains()
contains() function determines whether a string contains a given substring. This function requires two mandatory string arguments.
contains(str, sub_str)
True when the substring (sub_str) is contained anywhere inside the string (str).
-
The
contains('Citrix', 'tri')function returnsTrue. -
The
contains('Citrix', 'Ci')function returnsTrue. -
The
contains('Citrix', 'ti')function returnsFalse
substring()
substring() function to extract a substring from a string.
substring(str, start_index, end_index)
-
str(Mandatory) -
start_index(Mandatory) -
end_index(Optional)
str) that is between the specified index positions. If you do not specify the end index position, the function extracts the substring from the start index to the end of the string.
end_index, the substring excludes the character at the end_index position.
-
The
substring('Citrix', 2)function returnstrix -
The
substring('Citrix', 10)function returns (")In this example, the function returns a blank string because it has an invalidstart_indexposition. -
The
substring('Citrix', 2, 4)function returnstrIn this example, the function extracts the characters between 2 and 4 index positions. -
The
substring('Citrix', -3)function returnsrixIf you want to extract characters that are at the end of the string, specify a negative value for thestart_indexargument.In this example, the function extracts the substring that includes the last three characters in the string.