Created
November 14, 2015 11:59
-
-
Save tjormola/eb05cb21a0b8a7f1aae3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body common control | |
{ | |
bundlesequence => { "datatest" }; | |
} | |
body agent control | |
{ | |
ifelapsed => 0; | |
} | |
bundle agent datatest | |
{ | |
vars: | |
"data_with_list_of_strings" data => parsejson('{"key":["item1","item2"]}'); | |
"data_with_list_of_maps" data => parsejson('{"key":[{"name":"item1","url":"url1"},{"name":"item2","url":"url2"}]}'); | |
methods: | |
# "handle_list_of_strings" usebundle => handle_list_of_strings(@(data_with_list_of_strings[key])); | |
"handle_list_of_maps" usebundle => handle_list_of_maps(@(data_with_list_of_maps[key])); | |
} | |
bundle agent handle_list_of_strings(list) | |
{ | |
vars: | |
"list_str" string => format("%S", list); | |
methods: | |
# Bundle is applied for each item in the list | |
"handle_list_items" usebundle => handle_string_item($(list)); | |
reports: | |
"$(this.bundle) called with list $(list_str)"; | |
} | |
bundle agent handle_list_of_maps(list) | |
{ | |
vars: | |
"list_str" string => format("%S", list); | |
"indices" slist => getindices(list); | |
methods: | |
"handle_list_items" usebundle => handle_map_item($(list[$(indices)])); | |
reports: | |
"$(this.bundle) called with list $(list_str)"; | |
"$(this.bundle) list has item with name $(list[$(indices)][name]) and url $(list[$(indices)][url])"; | |
} | |
bundle agent handle_string_item(item) | |
{ | |
reports: | |
"$(this.bundle) called with item $(item)"; | |
} | |
bundle agent handle_map_item(item) | |
{ | |
vars: | |
# "item_str" string => format("%S", item); | |
#methods: | |
# "handle_string_item" usebundle => handle_string_item($(item[name])); | |
reports: | |
"$(this.bundle) called with item $(item)"; | |
} |
Author
tjormola
commented
Nov 14, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment