So I have been working with the IC2 API for a few years now, and done a lot of empirical testing.
Honestly, the documentation is sometimes a bit lacking. For calls that take data, sometimes the data requested isn’t shown, and you basically have to manually create what you want via IC2 then query the API, and use those results as a template. This is something I have been doing since the beginning of hammering on the API.
Additionally, sometimes there are parameters that aren’t obvious by their naming just what they do, and you just have to poke at it for a while. One example is GET /rest/o/{organization_id}/g which has the parameter is_show_detail that is indicated to be a boolean but is an entry field (other api call tests have booleans as a true/false pulldown), and using true or True or false or False or 0 or 1 seems to yield no difference in results.
Today I am wrestling with programatically creating firewall rulesets at the group level which reference organization wide grouped networks. I am finding that the API seems to be unable to do this or if it can, it is inadequately documented.
I am starting simple, with a single rule and named group. The named group is RFC1918 and includes the 3 RFC1918 networks (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16).
The ruleset contains one rule.
The rule is to be the lowest level internal rule (last place in the list, so it applies last) and will deny all RFC1918 to all other RFC1918 IPv4 traffic. This is roughly equivalent to disabling inter-VLAN communication, but permits us to add earlier allow rules as an override.
I have a Testing group, where I have manually input all of this. However, upon querying the firewall ruleset, I get data that makes no sense to me, and appears to have no reference at all to the RFC1918 grouped network.
Results from GET /rest/o/{organization_id}/g/{group_id}/firewall_rule_sets:
{
"resp_code": "SUCCESS",
"caller_ref": "2025061314045269918202",
"server_ref": "2025061314045226436664",
"data": [
{
"profile_id": 3,
"name": "DefaultBlockedRFC1918",
"device_tag_selection": "none",
"default_in_action": "accept",
"default_out_action": "accept",
"default_internal_action": "drop",
"sort_order": 9999,
"rules": [
{
"id": 1,
"name": "Default_Deny_RFC1918",
"direction": "internal",
"source_ip": "0.0.0.0",
"destination_ip": "0.0.0.0",
"destination_port": 0,
"protocol": "0",
"dscp": 0,
"action": "drop",
"enable": true,
"log": true,
"sort_order": 1
}
]
}
]
}
As you can see, there appears to be no reference to the RFC1918 grouped network.
Now if I use GET /rest/o/{organization_id}/g/{group_id}/firewall_rule_sets/{profile_id} using profile_id of 3 from above, I get these results:
{
"resp_code": "SUCCESS",
"caller_ref": "2025061314291068748926",
"server_ref": "2025061314291035245114",
"data": {
"profile_id": 3,
"name": "DefaultBlockedRFC1918",
"device_tag_selection": "none",
"default_in_action": "accept",
"default_out_action": "accept",
"default_internal_action": "drop",
"sort_order": 9999,
"rules": [
{
"id": 1,
"name": "Default_Deny_RFC1918",
"direction": "internal",
"source_ip": "0.0.0.0",
"destination_ip": "0.0.0.0",
"destination_port": 0,
"protocol": "0",
"dscp": 0,
"action": "drop",
"enable": true,
"log": true,
"sort_order": 1
}
]
}
}
Without being able to get a working example dataset out via the API, I cannot know how to create new rulesets that contain the RFC1918 grouped network rule. Additionally, I am concerned that making use of the POST method for “update firewall ruleset” will break the existing RFC1918 reference that is hidden from me.
Am I missing something? I would love to be wrong about this. But ultimately the question is this: how do I go about programatically creating or updating firewall rulesets that reference grouped networks via the IC2 API?
Thanks. At this point I am facing the purgatory of manually creating 20+ rulesets due to this issues.