Input values are configured in the scriptable step plugin through value map providers. For this purpose, Airlock IAM provides a large number of plugins. Refer to the plugin documentation for further information on a particular value map provider.
All the examples in this text configure the Input Map property with a Context Data Map plugin. To read a context data item, the iam.input_map[<key>]
table must be used in the script code.
The following example shows how a user's givenname
and surname
are concatenated into a property full_name
. This property is then logged and finally returned to IAM for further use.
function iam_on_step_init ()
iam.output_map = {}
iam.output_map["full_name"] = iam.input_map["givenname"] .. " " .. iam.input_map["surname"]
iam.log:info("User with full name: " .. iam.output_map["full_name"])
return iam.output_map
end
If multiple value map providers contain a key with the same name, the value from the last value map provider will overwrite previous values.
Optional input values
When configuring value provider maps with optional values, it is the script's responsibility to check whether a particular value is present. In case of a missing value, the iam.input_map[<key>]
will return the value nil
.
The following code example will check if the key givenname
is present or not:
if (iam.input_map["givenname"] ~= nil) then
<logic if given name is present>
else
<logic if given name is absent>
end
List all values provided to the script
The following code snippet will iterate over the table of input values provided to the script and output them to the IAM logfile:
for k, v in pairs(iam.input_map) do
iam.log:info("key : " .. k .. ", value: " .. v)
end
The following code snippet will achieve the same result, with less formatting:
iam.log:info("Complete input map of GET request step: " .. iam.cjson.encode(iam.input_map))