{ "version": "4.0", "name": "Tufin Networks Sync", "type": "REST_EVENT", "vendor_identifier": "Tufin", "event_type": [ "SCHEDULE" ], "content_type": "application/json", "instance_variables": [ { "name": "Network_View_Sync", "type": "STRING", "value": "default" } ], "steps": [ { "name": "Get_Zones_To_Sync", "operation": "GET", "parse": "JSON", "transport": { "path": "networkview?name=${I:A:Network_View_Sync}&_return_fields=name,extattrs" }, "wapi": "v2.7", "wapi_quoting": "JSON" }, { "name": "Copy_over_zones", "comment": "Check_if_zones_variable_is_empty", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${P:A:PARSE[0]{extattrs}{Tufin_Sync_Zones}{value}}", "op": "!=", "right": "" } ], "eval": "${XC:COPY:{L:zones}:{P:PARSE[0]{extattrs}{Tufin_Sync_Zones}{value}}", "else_stop": true } }, { "name": "Check_if_Any_Zones", "comment": "Check_if_zones_variable_is_empty", "operation": "CONDITION", "condition": { "condition_type": "OR", "statements": [ { "left": "${L:L:zones}", "op": "==", "right": "0" }, { "left": "${L:A:zones}", "op": "==", "right": "STOP" } ], "stop": true } }, { "name": "Check_zones_Variable_Type", "comment": "Check_zones_Variable_Type", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${L:T:zones}", "op": "==", "right": "L" } ], "next": "Pop_Zone_From_List" } }, { "name": "Check_if_zone_was_allready_assigned_once", "comment": "Check_if_zone_was_allready_assigned_once", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${L:A:zones}", "op": "==", "right": "STOP" } ], "stop": true, "else_eval": "${XC:COPY:{L:zone}:{L:zones}}${XC:COPY:{L:zone}:{L:zones}}${XC:ASSIGN:{L:zones}:{S:STOP}}${XC:ASSIGN:{L:zones}:{S:STOP}}", "else_next": "Get_Zone_ID" } }, { "name": "Pop_Zone_From_List", "comment": "Pop_Zone_From_List", "operation": "VARIABLEOP", "variable_ops": [ { "operation": "POP", "type": "SINGLE", "destination": "L:zone", "source": "L:zones" } ] }, { "name": "Get_Zone_ID", "operation": "GET", "parse": "JSON", "headers": { "Accept": "application/json" }, "transport": { "path": "/securetrack/api/zones?name=${L:A:zone}" } }, { "name": "Assign_Zone_ID", "comment": "Assign_Zone_ID", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${P:A:zones{zone}[0]{id}}", "op": "!=", "right": "" } ], "eval": "${XC:COPY:{L:ZoneID}:{P:zones{zone}[0]{id}}}", "else_next": "Check_if_Any_Zones" } }, { "name": "Get_Zone_Subnets", "operation": "GET", "parse": "JSON", "headers": { "Accept": "application/json" }, "transport": { "path": "/securetrack/api/zones/${L:A:ZoneID}/entries" } }, { "name": "Assign_Subnets", "comment": "Assign_Subnets", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${P:A:zone_entries{zone_entry}}", "op": "!=", "right": "" } ], "eval": "${XC:COPY:{L:Subnets}:{P:zone_entries{zone_entry}}}", "else_next": "Check_if_Any_Zones" } }, { "name": "Check_if_Any_Subnets", "comment": "Check_if_Subnets_variable_is_empty", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${L:L:Subnets}", "op": "==", "right": "0" } ], "next": "Check_if_Any_Zones" } }, { "name": "Check_Subnets_Variable_Type", "comment": "Check_Subnets_Variable_Type", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${L:T:Subnets}", "op": "==", "right": "L" } ], "next": "Pop_From_Subnets" } }, { "name": "Check_if_Subnet_was_allready_assigned", "comment": "Check_if_Subnet_was_allready_assigned", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${L:A:Subnets}", "op": "==", "right": "STOP" } ], "next": "Check_if_Any_Zones", "else_eval": "${XC:COPY:{L:Subnet}:{L:Subnets}}${XC:COPY:{L:Subnet}:{L:Subnets}}${XC:ASSIGN:{L:Subnets}:{S:STOP}}${XC:ASSIGN:{L:Subnets}:{S:STOP}}", "else_next": "Debug_After_Assigning_Subnets" } }, { "name": "Pop_From_Subnets", "comment": "Pop_From_Subnets", "operation": "VARIABLEOP", "variable_ops": [ { "operation": "POP", "type": "DICTIONARY", "destination": "L:Subnet", "source": "L:Subnets" } ] }, { "name": "Debug_After_Assigning_Subnets", "operation": "NOP", "body": "${XC:DEBUG:{E:}}${XC:DEBUG:{I:}}${XC:DEBUG:{L:}}${XC:DEBUG:{S:}}${XC:DEBUG:{P:}}" }, { "name": "Check_if_Subnet_IPV4_or_IPV6", "comment": "can't update lease because there is no EA to attach it to", "operation": "CONDITION", "condition": { "condition_type": "OR", "statements": [ { "left": "${L:A:Subnet{ip}}", "op": "!~", "right": ":" } ], "next": "Get_Current_Network_IPv4", "else_next": "Get_Current_Network_IPv6" } }, { "name": "Get_Current_Network_IPv4", "operation": "GET", "parse": "JSON", "transport": { "path": "network?network_view=${I:A:Network_View_Sync}&network=${L:A:Subnet{ip}}/${L:A:Subnet{prefix}}&_return_fields=network" }, "wapi": "v2.7", "wapi_quoting": "JSON" }, { "name": "Check_if_Network_Exists", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${P:A:PARSE[0]{network}}", "op": "!=", "right": "" } ], "next": "Check_if_Comment_Exists_For_Update" } }, { "name": "Get_Current_Network_IPv4_Container", "operation": "GET", "parse": "JSON", "transport": { "path": "networkcontainer?network_view=${I:A:Network_View_Sync}&network=${L:A:Subnet{ip}}/${L:A:Subnet{prefix}}&_return_fields=network" }, "wapi": "v2.7", "wapi_quoting": "JSON" }, { "name": "Check_if_Network_Container_Exists", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${P:A:PARSE[0]{network}}", "op": "!=", "right": "" } ], "next": "Check_if_Comment_Exists_For_Update_Container" } }, { "comment": "Check_if_Comment_Exists", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${L:A:Subnet{comment}}", "op": "==", "right": "" } ], "eval": "${XC:ASSIGN:{L:Subnet{comment}}:{S:}}" } }, { "name": "POST_New_Subnet", "operation": "POST", "parse": "JSON", "headers": { "Accept": "application/json" }, "transport": { "path": "/network" }, "wapi": "v2.7", "wapi_quoting": "JSON", "body_list": [ "{", "\"network\": \"${L:A:Subnet{ip}}/${L:A:Subnet{prefix}}\",", "\"comment\": \"${L:A:Subnet{comment}}\",", "\"network_view\": \"${I:A:Network_View_Sync}\",", "\"extattrs\":{\"Tufin_Zone\": { \"value\": \"${L:A:zone}\"}, \"Tufin_SyncTime\": { \"value\": \"${UT:U:TIME}\"}}", "}" ], "result": [ { "codes": "200,201,204,400", "next": "Check_If_Return_Code_400" } ] }, { "name": "Check_If_Return_Code_400", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${R:A:RC}", "op": "!=", "right": "400" } ], "next": "Check_if_Any_Subnets" } }, { "comment": "Check_if_Comment_Exists", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${L:A:Subnet{comment}}", "op": "==", "right": "" } ], "eval": "${XC:ASSIGN:{L:Subnet{comment}}:{S:}}" } }, { "name": "POST_New_Subnet_Container_IPv4", "operation": "POST", "parse": "JSON", "headers": { "Accept": "application/json" }, "transport": { "path": "/networkcontainer" }, "wapi": "v2.7", "wapi_quoting": "JSON", "body_list": [ "{", "\"network\": \"${L:A:Subnet{ip}}/${L:A:Subnet{prefix}}\",", "\"comment\": \"${L:A:Subnet{comment}}\",", "\"network_view\": \"${I:A:Network_View_Sync}\",", "\"extattrs\":{\"Tufin_Zone\": { \"value\": \"${L:A:zone}\"}, \"Tufin_SyncTime\": { \"value\": \"${UT:U:TIME}\"}}", "}" ], "result": [ { "codes": "200,201,204", "next": "Check_if_Any_Subnets" } ] }, { "name": "Check_if_Comment_Exists_For_Update", "comment": "Check_if_Comment_Exists", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${L:A:Subnet{comment}}", "op": "==", "right": "" } ], "eval": "${XC:ASSIGN:{L:Subnet{comment}}:{S:}}" } }, { "name": "Update_Subnet", "operation": "PUT", "parse": "JSON", "headers": { "Accept": "application/json" }, "transport": { "path": "${P:A:PARSE[0]{_ref}}" }, "wapi": "v2.7", "wapi_quoting": "JSON", "body_list": [ "{", "\"comment\": \"${L:A:Subnet{comment}}\",", "\"extattrs+\":{\"Tufin_Zone\": { \"value\": \"${L:A:zone}\"}, \"Tufin_SyncTime\": { \"value\": \"${UT:U:TIME}\"}}", "}" ], "result": [ { "codes": "200,201,204", "next": "Check_if_Any_Subnets" } ] }, { "name": "Check_if_Comment_Exists_For_Update_Container", "comment": "Check_if_Comment_Exists", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${L:A:Subnet{comment}}", "op": "==", "right": "" } ], "eval": "${XC:ASSIGN:{L:Subnet{comment}}:{S:}}" } }, { "name": "Update_Subnet_Container", "operation": "PUT", "parse": "JSON", "headers": { "Accept": "application/json" }, "transport": { "path": "${P:A:PARSE[0]{_ref}}" }, "wapi": "v2.7", "wapi_quoting": "JSON", "body_list": [ "{", "\"comment\": \"${L:A:Subnet{comment}}\",", "\"extattrs+\":{\"Tufin_Zone\": { \"value\": \"${L:A:zone}\"}, \"Tufin_SyncTime\": { \"value\": \"${UT:U:TIME}\"}}", "}" ], "result": [ { "codes": "200,201,204", "next": "Check_if_Any_Subnets" } ] }, { "name": "Get_Current_Network_IPv6", "operation": "GET", "parse": "JSON", "transport": { "path": "ipv6network?network_view=${I:A:Network_View_Sync}&network=${L:A:Subnet{ip}}/${L:A:Subnet{prefix}}&_return_fields=network" }, "wapi": "v2.7", "wapi_quoting": "JSON" }, { "name": "Check_if_Network_Exists_IPv6", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${P:A:PARSE[0]{network}}", "op": "!=", "right": "" } ], "next": "Check_if_Comment_Exists_For_Update_IPv6" } }, { "name": "Get_Current_Network_IPv6_Container", "operation": "GET", "parse": "JSON", "transport": { "path": "ipv6networkcontainer?network_view=${I:A:Network_View_Sync}&network=${L:A:Subnet{ip}}/${L:A:Subnet{prefix}}&_return_fields=network" }, "wapi": "v2.7", "wapi_quoting": "JSON" }, { "name": "Check_if_Network_Container_IPv6_Exists", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${P:A:PARSE[0]{network}}", "op": "!=", "right": "" } ], "next": "Check_if_Comment_Exists_For_Update_Container_IPv6" } }, { "comment": "Check_if_Comment_Exists", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${L:A:Subnet{comment}}", "op": "==", "right": "" } ], "eval": "${XC:ASSIGN:{L:Subnet{comment}}:{S:}}" } }, { "name": "POST_New_Subnet_IPv6", "operation": "POST", "parse": "JSON", "headers": { "Accept": "application/json" }, "transport": { "path": "/ipv6network" }, "wapi": "v2.7", "wapi_quoting": "JSON", "body_list": [ "{", "\"network\": \"${L:A:Subnet{ip}}/${L:A:Subnet{prefix}}\",", "\"comment\": \"${L:A:Subnet{comment}}\",", "\"network_view\": \"${I:A:Network_View_Sync}\",", "\"extattrs\":{\"Tufin_Zone\": { \"value\": \"${L:A:zone}\"}, \"Tufin_SyncTime\": { \"value\": \"${UT:U:TIME}\"}}", "}" ], "result": [ { "codes": "200,201,204,400", "next": "Check_If_Return_Code_400" } ] }, { "name": "Check_If_Return_Code_400_IPv6", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${R:A:RC}", "op": "!=", "right": "400" } ], "next": "Check_if_Any_Subnets" } }, { "comment": "Check_if_Comment_Exists", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${L:A:Subnet{comment}}", "op": "==", "right": "" } ], "eval": "${XC:ASSIGN:{L:Subnet{comment}}:{S:}}" } }, { "name": "POST_New_Subnet_Container_IPv6", "operation": "POST", "parse": "JSON", "headers": { "Accept": "application/json" }, "transport": { "path": "/ipv6networkcontainer" }, "wapi": "v2.7", "wapi_quoting": "JSON", "body_list": [ "{", "\"network\": \"${L:A:Subnet{ip}}/${L:A:Subnet{prefix}}\",", "\"comment\": \"${L:A:Subnet{comment}}\",", "\"network_view\": \"${I:A:Network_View_Sync}\",", "\"extattrs\":{\"Tufin_Zone\": { \"value\": \"${L:A:zone}\"}, \"Tufin_SyncTime\": { \"value\": \"${UT:U:TIME}\"}}", "}" ], "result": [ { "codes": "200,201,204", "next": "Check_if_Any_Subnets" } ] }, { "name": "Check_if_Comment_Exists_For_Update_IPv6", "comment": "Check_if_Comment_Exists", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${L:A:Subnet{comment}}", "op": "==", "right": "" } ], "eval": "${XC:ASSIGN:{L:Subnet{comment}}:{S:}}" } }, { "name": "Update_Subnet_IPv6", "operation": "PUT", "parse": "JSON", "headers": { "Accept": "application/json" }, "transport": { "path": "${P:A:PARSE[0]{_ref}}" }, "wapi": "v2.7", "wapi_quoting": "JSON", "body_list": [ "{", "\"comment\": \"${L:A:Subnet{comment}}\",", "\"extattrs+\":{\"Tufin_Zone\": { \"value\": \"${L:A:zone}\"}, \"Tufin_SyncTime\": { \"value\": \"${UT:U:TIME}\"}}", "}" ], "result": [ { "codes": "200,201,204", "next": "Check_if_Any_Subnets" } ] }, { "name": "Check_if_Comment_Exists_For_Update_Container_IPv6", "comment": "Check_if_Comment_Exists", "operation": "CONDITION", "condition": { "condition_type": "AND", "statements": [ { "left": "${L:A:Subnet{comment}}", "op": "==", "right": "" } ], "eval": "${XC:ASSIGN:{L:Subnet{comment}}:{S:}}" } }, { "name": "Update_Subnet_Container_IPv6", "operation": "PUT", "parse": "JSON", "headers": { "Accept": "application/json" }, "transport": { "path": "${P:A:PARSE[0]{_ref}}" }, "wapi": "v2.7", "wapi_quoting": "JSON", "body_list": [ "{", "\"comment\": \"${L:A:Subnet{comment}}\",", "\"extattrs+\":{\"Tufin_Zone\": { \"value\": \"${L:A:zone}\"}, \"Tufin_SyncTime\": { \"value\": \"${UT:U:TIME}\"}}", "}" ], "result": [ { "codes": "200,201,204", "next": "Check_if_Any_Subnets" } ] }, { "name": "STOP", "operation": "CONDITION", "condition": { "statements": [ { "left": "1", "op": "==", "right": "1" } ], "condition_type": "OR", "stop": true } } ] }