catocli 2.0.5__py3-none-any.whl → 2.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of catocli might be problematic. Click here for more details.

Files changed (361) hide show
  1. catocli/Utils/clidriver.py +10 -0
  2. catocli/__init__.py +1 -1
  3. catocli/parsers/custom/export_sites/export_sites.py +18 -1
  4. catocli/parsers/custom/import_sites_to_tf/__init__.py +3 -1
  5. catocli/parsers/custom/import_sites_to_tf/import_sites_to_tf.py +71 -5
  6. catocli/parsers/mutation_accountManagement/__init__.py +13 -0
  7. catocli/parsers/mutation_accountManagement_disableAccount/README.md +16 -0
  8. catocli/parsers/mutation_groups/README.md +7 -0
  9. catocli/parsers/mutation_groups/__init__.py +48 -0
  10. catocli/parsers/mutation_groups_createGroup/README.md +18 -0
  11. catocli/parsers/mutation_groups_deleteGroup/README.md +18 -0
  12. catocli/parsers/mutation_groups_updateGroup/README.md +18 -0
  13. catocli/parsers/mutation_site/__init__.py +104 -0
  14. catocli/parsers/mutation_site_assignSiteBwLicense/README.md +17 -0
  15. catocli/parsers/mutation_site_removeSecondaryAwsVSocket/README.md +17 -0
  16. catocli/parsers/mutation_site_removeSecondaryAzureVSocket/README.md +17 -0
  17. catocli/parsers/mutation_site_removeSiteBwLicense/README.md +17 -0
  18. catocli/parsers/mutation_site_replaceSiteBwLicense/README.md +17 -0
  19. catocli/parsers/mutation_site_updateSecondaryAwsVSocket/README.md +17 -0
  20. catocli/parsers/mutation_site_updateSecondaryAzureVSocket/README.md +17 -0
  21. catocli/parsers/mutation_site_updateSiteBwLicense/README.md +17 -0
  22. catocli/parsers/mutation_site_updateSiteGeneralDetails/README.md +1 -1
  23. catocli/parsers/mutation_sites/__init__.py +104 -0
  24. catocli/parsers/mutation_sites_assignSiteBwLicense/README.md +17 -0
  25. catocli/parsers/mutation_sites_removeSecondaryAwsVSocket/README.md +17 -0
  26. catocli/parsers/mutation_sites_removeSecondaryAzureVSocket/README.md +17 -0
  27. catocli/parsers/mutation_sites_removeSiteBwLicense/README.md +17 -0
  28. catocli/parsers/mutation_sites_replaceSiteBwLicense/README.md +17 -0
  29. catocli/parsers/mutation_sites_updateSecondaryAwsVSocket/README.md +17 -0
  30. catocli/parsers/mutation_sites_updateSecondaryAzureVSocket/README.md +17 -0
  31. catocli/parsers/mutation_sites_updateSiteBwLicense/README.md +17 -0
  32. catocli/parsers/mutation_sites_updateSiteGeneralDetails/README.md +1 -1
  33. catocli/parsers/parserApiClient.py +17 -8
  34. catocli/parsers/query_eventsFeed/README.md +1 -1
  35. catocli/parsers/query_groups/README.md +7 -0
  36. catocli/parsers/query_groups/__init__.py +54 -0
  37. catocli/parsers/query_groups_group/README.md +7 -0
  38. catocli/parsers/query_groups_groupList/README.md +18 -0
  39. catocli/parsers/query_groups_group_members/README.md +18 -0
  40. catocli/parsers/query_groups_whereUsed/README.md +17 -0
  41. catocli/parsers/query_popLocations/README.md +17 -0
  42. catocli/parsers/query_popLocations/__init__.py +16 -0
  43. catocli/parsers/query_site/__init__.py +26 -0
  44. catocli/parsers/query_site_secondaryAwsVSocket/README.md +17 -0
  45. catocli/parsers/query_site_secondaryAzureVSocket/README.md +17 -0
  46. catocli/parsers/query_socketPortMetrics/README.md +23 -0
  47. catocli/parsers/query_socketPortMetrics/__init__.py +16 -0
  48. catocli/parsers/query_socketPortMetricsTimeSeries/README.md +24 -0
  49. catocli/parsers/query_socketPortMetricsTimeSeries/__init__.py +16 -0
  50. {catocli-2.0.5.dist-info → catocli-2.1.0.dist-info}/METADATA +3 -2
  51. {catocli-2.0.5.dist-info → catocli-2.1.0.dist-info}/RECORD +249 -297
  52. {catocli-2.0.5.dist-info → catocli-2.1.0.dist-info}/WHEEL +1 -1
  53. {catocli-2.0.5.dist-info → catocli-2.1.0.dist-info}/top_level.txt +0 -2
  54. models/mutation.accountManagement.addAccount.json +97 -0
  55. models/mutation.accountManagement.disableAccount.json +545 -0
  56. models/mutation.accountManagement.removeAccount.json +102 -3
  57. models/mutation.accountManagement.updateAccount.json +97 -0
  58. models/mutation.admin.addAdmin.json +6 -9
  59. models/mutation.container.delete.json +2 -2
  60. models/mutation.container.fqdn.addValues.json +3 -3
  61. models/mutation.container.fqdn.createFromFile.json +3 -3
  62. models/mutation.container.fqdn.removeValues.json +3 -3
  63. models/mutation.container.fqdn.updateFromFile.json +3 -3
  64. models/mutation.container.ipAddressRange.addValues.json +3 -3
  65. models/mutation.container.ipAddressRange.createFromFile.json +3 -3
  66. models/mutation.container.ipAddressRange.removeValues.json +3 -3
  67. models/mutation.container.ipAddressRange.updateFromFile.json +3 -3
  68. models/mutation.groups.createGroup.json +3178 -0
  69. models/mutation.groups.deleteGroup.json +2758 -0
  70. models/mutation.groups.updateGroup.json +4429 -0
  71. models/mutation.hardware.updateHardwareShipping.json +30 -10
  72. models/mutation.policy.appTenantRestriction.addRule.json +33 -33
  73. models/mutation.policy.appTenantRestriction.addSection.json +4 -4
  74. models/mutation.policy.appTenantRestriction.createPolicyRevision.json +33 -33
  75. models/mutation.policy.appTenantRestriction.discardPolicyRevision.json +33 -33
  76. models/mutation.policy.appTenantRestriction.moveRule.json +27 -27
  77. models/mutation.policy.appTenantRestriction.moveSection.json +4 -4
  78. models/mutation.policy.appTenantRestriction.publishPolicyRevision.json +33 -33
  79. models/mutation.policy.appTenantRestriction.removeRule.json +27 -27
  80. models/mutation.policy.appTenantRestriction.removeSection.json +4 -4
  81. models/mutation.policy.appTenantRestriction.updatePolicy.json +33 -33
  82. models/mutation.policy.appTenantRestriction.updateRule.json +33 -33
  83. models/mutation.policy.appTenantRestriction.updateSection.json +4 -4
  84. models/mutation.policy.dynamicIpAllocation.addRule.json +12 -12
  85. models/mutation.policy.dynamicIpAllocation.addSection.json +4 -4
  86. models/mutation.policy.dynamicIpAllocation.createPolicyRevision.json +18 -18
  87. models/mutation.policy.dynamicIpAllocation.discardPolicyRevision.json +18 -18
  88. models/mutation.policy.dynamicIpAllocation.moveRule.json +12 -12
  89. models/mutation.policy.dynamicIpAllocation.moveSection.json +4 -4
  90. models/mutation.policy.dynamicIpAllocation.publishPolicyRevision.json +18 -18
  91. models/mutation.policy.dynamicIpAllocation.removeRule.json +12 -12
  92. models/mutation.policy.dynamicIpAllocation.removeSection.json +4 -4
  93. models/mutation.policy.dynamicIpAllocation.updatePolicy.json +18 -18
  94. models/mutation.policy.dynamicIpAllocation.updateRule.json +12 -12
  95. models/mutation.policy.dynamicIpAllocation.updateSection.json +4 -4
  96. models/mutation.policy.internetFirewall.addRule.json +141 -141
  97. models/mutation.policy.internetFirewall.addSection.json +4 -4
  98. models/mutation.policy.internetFirewall.createPolicyRevision.json +102 -102
  99. models/mutation.policy.internetFirewall.discardPolicyRevision.json +102 -102
  100. models/mutation.policy.internetFirewall.moveRule.json +96 -96
  101. models/mutation.policy.internetFirewall.moveSection.json +4 -4
  102. models/mutation.policy.internetFirewall.publishPolicyRevision.json +102 -102
  103. models/mutation.policy.internetFirewall.removeRule.json +96 -96
  104. models/mutation.policy.internetFirewall.removeSection.json +4 -4
  105. models/mutation.policy.internetFirewall.updatePolicy.json +102 -102
  106. models/mutation.policy.internetFirewall.updateRule.json +141 -141
  107. models/mutation.policy.internetFirewall.updateSection.json +4 -4
  108. models/mutation.policy.remotePortFwd.addRule.json +21 -21
  109. models/mutation.policy.remotePortFwd.addSection.json +4 -4
  110. models/mutation.policy.remotePortFwd.createPolicyRevision.json +24 -24
  111. models/mutation.policy.remotePortFwd.discardPolicyRevision.json +24 -24
  112. models/mutation.policy.remotePortFwd.moveRule.json +18 -18
  113. models/mutation.policy.remotePortFwd.moveSection.json +4 -4
  114. models/mutation.policy.remotePortFwd.publishPolicyRevision.json +24 -24
  115. models/mutation.policy.remotePortFwd.removeRule.json +18 -18
  116. models/mutation.policy.remotePortFwd.removeSection.json +4 -4
  117. models/mutation.policy.remotePortFwd.updatePolicy.json +24 -24
  118. models/mutation.policy.remotePortFwd.updateRule.json +21 -21
  119. models/mutation.policy.remotePortFwd.updateSection.json +4 -4
  120. models/mutation.policy.socketLan.addRule.json +97 -97
  121. models/mutation.policy.socketLan.addSection.json +4 -4
  122. models/mutation.policy.socketLan.createPolicyRevision.json +91 -91
  123. models/mutation.policy.socketLan.discardPolicyRevision.json +91 -91
  124. models/mutation.policy.socketLan.moveRule.json +85 -85
  125. models/mutation.policy.socketLan.moveSection.json +4 -4
  126. models/mutation.policy.socketLan.publishPolicyRevision.json +91 -91
  127. models/mutation.policy.socketLan.removeRule.json +85 -85
  128. models/mutation.policy.socketLan.removeSection.json +4 -4
  129. models/mutation.policy.socketLan.updatePolicy.json +91 -91
  130. models/mutation.policy.socketLan.updateRule.json +97 -97
  131. models/mutation.policy.socketLan.updateSection.json +4 -4
  132. models/mutation.policy.terminalServer.addRule.json +7 -7
  133. models/mutation.policy.terminalServer.addSection.json +4 -4
  134. models/mutation.policy.terminalServer.createPolicyRevision.json +13 -13
  135. models/mutation.policy.terminalServer.discardPolicyRevision.json +13 -13
  136. models/mutation.policy.terminalServer.moveRule.json +7 -7
  137. models/mutation.policy.terminalServer.moveSection.json +4 -4
  138. models/mutation.policy.terminalServer.publishPolicyRevision.json +13 -13
  139. models/mutation.policy.terminalServer.removeRule.json +7 -7
  140. models/mutation.policy.terminalServer.removeSection.json +4 -4
  141. models/mutation.policy.terminalServer.updatePolicy.json +13 -13
  142. models/mutation.policy.terminalServer.updateRule.json +7 -7
  143. models/mutation.policy.terminalServer.updateSection.json +4 -4
  144. models/mutation.policy.wanFirewall.addRule.json +157 -157
  145. models/mutation.policy.wanFirewall.addSection.json +4 -4
  146. models/mutation.policy.wanFirewall.createPolicyRevision.json +121 -121
  147. models/mutation.policy.wanFirewall.discardPolicyRevision.json +121 -121
  148. models/mutation.policy.wanFirewall.moveRule.json +115 -115
  149. models/mutation.policy.wanFirewall.moveSection.json +4 -4
  150. models/mutation.policy.wanFirewall.publishPolicyRevision.json +121 -121
  151. models/mutation.policy.wanFirewall.removeRule.json +115 -115
  152. models/mutation.policy.wanFirewall.removeSection.json +4 -4
  153. models/mutation.policy.wanFirewall.updatePolicy.json +121 -121
  154. models/mutation.policy.wanFirewall.updateRule.json +157 -157
  155. models/mutation.policy.wanFirewall.updateSection.json +4 -4
  156. models/mutation.policy.wanNetwork.addRule.json +103 -103
  157. models/mutation.policy.wanNetwork.addSection.json +4 -4
  158. models/mutation.policy.wanNetwork.createPolicyRevision.json +97 -97
  159. models/mutation.policy.wanNetwork.discardPolicyRevision.json +97 -97
  160. models/mutation.policy.wanNetwork.moveRule.json +91 -91
  161. models/mutation.policy.wanNetwork.moveSection.json +4 -4
  162. models/mutation.policy.wanNetwork.publishPolicyRevision.json +97 -97
  163. models/mutation.policy.wanNetwork.removeRule.json +91 -91
  164. models/mutation.policy.wanNetwork.removeSection.json +4 -4
  165. models/mutation.policy.wanNetwork.updatePolicy.json +97 -97
  166. models/mutation.policy.wanNetwork.updateRule.json +103 -103
  167. models/mutation.policy.wanNetwork.updateSection.json +4 -4
  168. models/mutation.site.addBgpPeer.json +10 -10
  169. models/mutation.site.addIpsecIkeV2SiteTunnels.json +2 -2
  170. models/mutation.site.addSocketAddOnCard.json +2 -2
  171. models/mutation.site.assignSiteBwLicense.json +12879 -0
  172. models/mutation.site.removeBgpPeer.json +10 -10
  173. models/mutation.site.removeIpsecIkeV2SiteTunnels.json +2 -2
  174. models/mutation.site.removeSecondaryAwsVSocket.json +375 -0
  175. models/mutation.site.removeSecondaryAzureVSocket.json +354 -0
  176. models/mutation.site.removeSiteBwLicense.json +12822 -0
  177. models/mutation.site.removeSocketAddOnCard.json +2 -2
  178. models/mutation.site.replaceSiteBwLicense.json +12939 -0
  179. models/mutation.site.startSiteUpgrade.json +36 -15
  180. models/mutation.site.updateBgpPeer.json +10 -10
  181. models/mutation.site.updateIpsecIkeV2SiteTunnels.json +2 -2
  182. models/mutation.site.updateSecondaryAwsVSocket.json +643 -0
  183. models/mutation.site.updateSecondaryAzureVSocket.json +565 -0
  184. models/mutation.site.updateSiteBwLicense.json +12882 -0
  185. models/mutation.site.updateSiteGeneralDetails.json +724 -1
  186. models/mutation.sites.addBgpPeer.json +10 -10
  187. models/mutation.sites.addIpsecIkeV2SiteTunnels.json +2 -2
  188. models/mutation.sites.addSocketAddOnCard.json +2 -2
  189. models/mutation.sites.assignSiteBwLicense.json +12879 -0
  190. models/mutation.sites.removeBgpPeer.json +10 -10
  191. models/mutation.sites.removeIpsecIkeV2SiteTunnels.json +2 -2
  192. models/mutation.sites.removeSecondaryAwsVSocket.json +375 -0
  193. models/mutation.sites.removeSecondaryAzureVSocket.json +354 -0
  194. models/mutation.sites.removeSiteBwLicense.json +12822 -0
  195. models/mutation.sites.removeSocketAddOnCard.json +2 -2
  196. models/mutation.sites.replaceSiteBwLicense.json +12939 -0
  197. models/mutation.sites.startSiteUpgrade.json +36 -15
  198. models/mutation.sites.updateBgpPeer.json +10 -10
  199. models/mutation.sites.updateIpsecIkeV2SiteTunnels.json +2 -2
  200. models/mutation.sites.updateSecondaryAwsVSocket.json +643 -0
  201. models/mutation.sites.updateSecondaryAzureVSocket.json +565 -0
  202. models/mutation.sites.updateSiteBwLicense.json +12882 -0
  203. models/mutation.sites.updateSiteGeneralDetails.json +724 -1
  204. models/mutation.xdr.addStoryComment.json +1 -1
  205. models/mutation.xdr.analystFeedback.json +84 -84
  206. models/mutation.xdr.deleteStoryComment.json +1 -1
  207. models/query.accountManagement.json +97 -0
  208. models/query.accountMetrics.json +45 -45
  209. models/query.accountSnapshot.json +30 -30
  210. models/query.admin.json +6 -6
  211. models/query.admins.json +13 -13
  212. models/query.appStats.json +915 -867
  213. models/query.appStatsTimeSeries.json +692 -656
  214. models/query.auditFeed.json +6 -6
  215. models/query.catalogs.json +52 -52
  216. models/query.container.json +16 -16
  217. models/query.devices.json +20 -93
  218. models/query.entityLookup.json +2 -2
  219. models/query.events.json +288 -384
  220. models/query.eventsFeed.json +73 -97
  221. models/query.eventsTimeSeries.json +219 -291
  222. models/query.groups.group.members.json +3058 -0
  223. models/query.groups.groupList.json +6474 -0
  224. models/query.groups.whereUsed.json +697 -0
  225. models/query.hardware.json +27 -7
  226. models/query.hardwareManagement.json +8 -8
  227. models/query.licensing.json +3487 -1324
  228. models/query.policy.appTenantRestriction.policy.json +32 -32
  229. models/query.policy.dynamicIpAllocation.policy.json +18 -18
  230. models/query.policy.internetFirewall.policy.json +93 -93
  231. models/query.policy.remotePortFwd.policy.json +23 -23
  232. models/query.policy.socketLan.policy.json +88 -88
  233. models/query.policy.terminalServer.policy.json +13 -13
  234. models/query.policy.wanFirewall.policy.json +111 -111
  235. models/query.policy.wanNetwork.policy.json +97 -97
  236. models/query.popLocations.json +2878 -0
  237. models/query.sandbox.json +5 -5
  238. models/query.site.bgpPeer.json +4 -4
  239. models/query.site.bgpPeerList.json +10 -10
  240. models/query.site.secondaryAwsVSocket.json +340 -0
  241. models/query.site.secondaryAzureVSocket.json +319 -0
  242. models/query.site.siteBgpStatus.json +2 -2
  243. models/query.socketPortMetrics.json +2410 -0
  244. models/query.socketPortMetricsTimeSeries.json +2361 -0
  245. models/query.xdr.stories.json +104 -104
  246. models/query.xdr.story.json +93 -93
  247. schema/catolib.py +21 -12
  248. build/lib/catocli/Utils/clidriver.py +0 -268
  249. build/lib/catocli/Utils/profile_manager.py +0 -188
  250. build/lib/catocli/Utils/version_checker.py +0 -192
  251. build/lib/catocli/__init__.py +0 -2
  252. build/lib/catocli/__main__.py +0 -12
  253. build/lib/catocli/parsers/configure/__init__.py +0 -115
  254. build/lib/catocli/parsers/configure/configure.py +0 -307
  255. build/lib/catocli/parsers/custom/__init__.py +0 -57
  256. build/lib/catocli/parsers/custom/customLib.py +0 -561
  257. build/lib/catocli/parsers/custom/export_rules/__init__.py +0 -42
  258. build/lib/catocli/parsers/custom/export_rules/export_rules.py +0 -234
  259. build/lib/catocli/parsers/custom/export_sites/__init__.py +0 -21
  260. build/lib/catocli/parsers/custom/export_sites/export_sites.py +0 -372
  261. build/lib/catocli/parsers/custom/import_rules_to_tf/__init__.py +0 -58
  262. build/lib/catocli/parsers/custom/import_rules_to_tf/import_rules_to_tf.py +0 -451
  263. build/lib/catocli/parsers/custom/import_sites_to_tf/__init__.py +0 -45
  264. build/lib/catocli/parsers/custom/import_sites_to_tf/import_sites_to_tf.py +0 -891
  265. build/lib/catocli/parsers/mutation_accountManagement/__init__.py +0 -48
  266. build/lib/catocli/parsers/mutation_admin/__init__.py +0 -48
  267. build/lib/catocli/parsers/mutation_container/__init__.py +0 -138
  268. build/lib/catocli/parsers/mutation_hardware/__init__.py +0 -22
  269. build/lib/catocli/parsers/mutation_policy/__init__.py +0 -1305
  270. build/lib/catocli/parsers/mutation_sandbox/__init__.py +0 -35
  271. build/lib/catocli/parsers/mutation_site/__init__.py +0 -373
  272. build/lib/catocli/parsers/mutation_sites/__init__.py +0 -373
  273. build/lib/catocli/parsers/mutation_xdr/__init__.py +0 -48
  274. build/lib/catocli/parsers/parserApiClient.py +0 -513
  275. build/lib/catocli/parsers/query_accountBySubdomain/__init__.py +0 -16
  276. build/lib/catocli/parsers/query_accountManagement/__init__.py +0 -16
  277. build/lib/catocli/parsers/query_accountMetrics/__init__.py +0 -16
  278. build/lib/catocli/parsers/query_accountRoles/__init__.py +0 -16
  279. build/lib/catocli/parsers/query_accountSnapshot/__init__.py +0 -16
  280. build/lib/catocli/parsers/query_admin/__init__.py +0 -16
  281. build/lib/catocli/parsers/query_admins/__init__.py +0 -16
  282. build/lib/catocli/parsers/query_appStats/__init__.py +0 -16
  283. build/lib/catocli/parsers/query_appStatsTimeSeries/__init__.py +0 -16
  284. build/lib/catocli/parsers/query_auditFeed/__init__.py +0 -16
  285. build/lib/catocli/parsers/query_catalogs/__init__.py +0 -16
  286. build/lib/catocli/parsers/query_container/__init__.py +0 -16
  287. build/lib/catocli/parsers/query_devices/__init__.py +0 -16
  288. build/lib/catocli/parsers/query_entityLookup/__init__.py +0 -16
  289. build/lib/catocli/parsers/query_events/__init__.py +0 -16
  290. build/lib/catocli/parsers/query_eventsFeed/__init__.py +0 -16
  291. build/lib/catocli/parsers/query_eventsTimeSeries/__init__.py +0 -16
  292. build/lib/catocli/parsers/query_hardware/__init__.py +0 -16
  293. build/lib/catocli/parsers/query_hardwareManagement/__init__.py +0 -16
  294. build/lib/catocli/parsers/query_licensing/__init__.py +0 -16
  295. build/lib/catocli/parsers/query_policy/__init__.py +0 -161
  296. build/lib/catocli/parsers/query_sandbox/__init__.py +0 -16
  297. build/lib/catocli/parsers/query_site/__init__.py +0 -100
  298. build/lib/catocli/parsers/query_siteLocation/__init__.py +0 -13
  299. build/lib/catocli/parsers/query_subDomains/__init__.py +0 -16
  300. build/lib/catocli/parsers/query_xdr/__init__.py +0 -35
  301. build/lib/catocli/parsers/raw/__init__.py +0 -12
  302. build/lib/graphql_client/__init__.py +0 -11
  303. build/lib/graphql_client/api/__init__.py +0 -3
  304. build/lib/graphql_client/api/call_api.py +0 -84
  305. build/lib/graphql_client/api_client.py +0 -192
  306. build/lib/graphql_client/api_client_types.py +0 -409
  307. build/lib/graphql_client/configuration.py +0 -232
  308. build/lib/graphql_client/models/__init__.py +0 -13
  309. build/lib/graphql_client/models/no_schema.py +0 -71
  310. build/lib/schema/catolib.py +0 -1141
  311. build/lib/schema/importSchema.py +0 -60
  312. build/lib/schema/remove_policyid.py +0 -89
  313. build/lib/schema/remove_policyid_mutations.py +0 -89
  314. build/lib/scripts/catolib.py +0 -62
  315. build/lib/scripts/export_if_rules_to_json.py +0 -188
  316. build/lib/scripts/export_wf_rules_to_json.py +0 -111
  317. build/lib/scripts/import_wf_rules_to_tfstate.py +0 -331
  318. build/lib/vendor/certifi/__init__.py +0 -4
  319. build/lib/vendor/certifi/__main__.py +0 -12
  320. build/lib/vendor/certifi/core.py +0 -114
  321. build/lib/vendor/certifi/py.typed +0 -0
  322. build/lib/vendor/six.py +0 -998
  323. build/lib/vendor/urllib3/__init__.py +0 -211
  324. build/lib/vendor/urllib3/_base_connection.py +0 -172
  325. build/lib/vendor/urllib3/_collections.py +0 -483
  326. build/lib/vendor/urllib3/_request_methods.py +0 -278
  327. build/lib/vendor/urllib3/_version.py +0 -16
  328. build/lib/vendor/urllib3/connection.py +0 -1033
  329. build/lib/vendor/urllib3/connectionpool.py +0 -1182
  330. build/lib/vendor/urllib3/contrib/__init__.py +0 -0
  331. build/lib/vendor/urllib3/contrib/emscripten/__init__.py +0 -18
  332. build/lib/vendor/urllib3/contrib/emscripten/connection.py +0 -254
  333. build/lib/vendor/urllib3/contrib/emscripten/fetch.py +0 -418
  334. build/lib/vendor/urllib3/contrib/emscripten/request.py +0 -22
  335. build/lib/vendor/urllib3/contrib/emscripten/response.py +0 -285
  336. build/lib/vendor/urllib3/contrib/pyopenssl.py +0 -552
  337. build/lib/vendor/urllib3/contrib/socks.py +0 -228
  338. build/lib/vendor/urllib3/exceptions.py +0 -321
  339. build/lib/vendor/urllib3/fields.py +0 -341
  340. build/lib/vendor/urllib3/filepost.py +0 -89
  341. build/lib/vendor/urllib3/http2/__init__.py +0 -53
  342. build/lib/vendor/urllib3/http2/connection.py +0 -356
  343. build/lib/vendor/urllib3/http2/probe.py +0 -87
  344. build/lib/vendor/urllib3/poolmanager.py +0 -637
  345. build/lib/vendor/urllib3/py.typed +0 -2
  346. build/lib/vendor/urllib3/response.py +0 -1265
  347. build/lib/vendor/urllib3/util/__init__.py +0 -42
  348. build/lib/vendor/urllib3/util/connection.py +0 -137
  349. build/lib/vendor/urllib3/util/proxy.py +0 -43
  350. build/lib/vendor/urllib3/util/request.py +0 -256
  351. build/lib/vendor/urllib3/util/response.py +0 -101
  352. build/lib/vendor/urllib3/util/retry.py +0 -533
  353. build/lib/vendor/urllib3/util/ssl_.py +0 -513
  354. build/lib/vendor/urllib3/util/ssl_match_hostname.py +0 -159
  355. build/lib/vendor/urllib3/util/ssltransport.py +0 -276
  356. build/lib/vendor/urllib3/util/timeout.py +0 -275
  357. build/lib/vendor/urllib3/util/url.py +0 -471
  358. build/lib/vendor/urllib3/util/util.py +0 -42
  359. build/lib/vendor/urllib3/util/wait.py +0 -124
  360. {catocli-2.0.5.dist-info → catocli-2.1.0.dist-info}/entry_points.txt +0 -0
  361. {catocli-2.0.5.dist-info → catocli-2.1.0.dist-info/licenses}/LICENSE +0 -0
@@ -1,60 +0,0 @@
1
- #!/usr/bin/python
2
- import catolib
3
- import logging
4
- import json
5
-
6
- ############ ENV Settings ############
7
- logging.basicConfig(filename="download-schema.log", filemode='w', format='%(name)s - %(levelname)s - %(message)s')
8
- options = catolib.initParser()
9
-
10
- def run():
11
- # ########################## OPTION 1 ##############################
12
- # ## Uncomment this secion to build cli as one continuous job
13
- # ##################################################################
14
- # query = {
15
- # 'query':'query IntrospectionQuery { __schema { description } }',
16
- # 'operationName':'IntrospectionQuery'
17
- # }
18
- # success,introspection = catolib.send(options.api_key,query)
19
- # catolib.parseSchema(introspection)
20
- # catolib.writeCliDriver(catolib.catoApiSchema)
21
- # catolib.writeOperationParsers(catolib.catoApiSchema)
22
- # catolib.writeReadmes(catolib.catoApiSchema)
23
- # ##################################################################
24
-
25
- ######################### OPTION 2 ##############################
26
- ## Uncomment to manually run each step manually writing files locally
27
- ######################### Step 1 ################################
28
- ## Run intrpsection to pull down schema and write locally
29
- #################################################################
30
- query = {
31
- 'query':'query IntrospectionQuery { __schema { description } }',
32
- 'operationName':'IntrospectionQuery'
33
- }
34
- success,resp = catolib.send(options.api_key,query)
35
- catolib.writeFile("introspection.json",json.dumps(resp, indent=4, sort_keys=True))
36
- # #################################################################
37
-
38
- ######################### Step 2 ################################
39
- ## Load from introsspeection from local file, and
40
- ## use catolib to parse the schema, write locally
41
- ## to catoApiIntrospection.json and catoApiSchema.json
42
- #################################################################
43
- introspection = catolib.loadJSON("introspection.json")
44
- catolib.parseSchema(introspection)
45
- catolib.writeFile("catoApiIntrospection.json",json.dumps(catolib.catoApiIntrospection, indent=4, sort_keys=True))
46
- catolib.writeFile("catoApiSchema.json",json.dumps(catolib.catoApiSchema, indent=4, sort_keys=True))
47
- #################################################################
48
-
49
- ####################### Step 3 ################################
50
- ## Load catoApiSchema from local file, and write cliDriver
51
- ## operation parsers, and readmes locally
52
- #############################################################
53
- catolib.catoApiSchema = catolib.loadJSON("catoApiSchema.json")
54
- catolib.writeCliDriver(catolib.catoApiSchema)
55
- catolib.writeOperationParsers(catolib.catoApiSchema)
56
- catolib.writeReadmes(catolib.catoApiSchema)
57
- ###############################################################
58
-
59
- if __name__ == '__main__':
60
- run()
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
- import json
4
- import glob
5
- import os
6
- import sys
7
-
8
- def remove_policy_id_from_object(obj, path=""):
9
- """
10
- Recursively remove policyId fields from a JSON object.
11
- """
12
- if isinstance(obj, dict):
13
- # Remove policyId field if it exists
14
- if "policyId" in obj:
15
- print(f"Removing policyId field at path: {path}")
16
- del obj["policyId"]
17
-
18
- # Recursively process all other fields
19
- for key, value in obj.items():
20
- new_path = f"{path}.{key}" if path else key
21
- remove_policy_id_from_object(value, new_path)
22
-
23
- elif isinstance(obj, list):
24
- # Process each item in the list
25
- for i, item in enumerate(obj):
26
- new_path = f"{path}[{i}]" if path else f"[{i}]"
27
- remove_policy_id_from_object(item, new_path)
28
-
29
- def process_file(file_path):
30
- """
31
- Process a single JSON file to remove policyId fields.
32
- """
33
- print(f"Processing file: {file_path}")
34
-
35
- try:
36
- # Read the JSON file
37
- with open(file_path, 'r') as f:
38
- data = json.load(f)
39
-
40
- # Remove policyId fields
41
- remove_policy_id_from_object(data, os.path.basename(file_path))
42
-
43
- # Write the modified JSON back to the file
44
- with open(file_path, 'w') as f:
45
- json.dump(data, f, indent=4, sort_keys=True)
46
-
47
- print(f"Successfully processed: {file_path}")
48
-
49
- except Exception as e:
50
- print(f"Error processing {file_path}: {e}")
51
- return False
52
-
53
- return True
54
-
55
- def main():
56
- # Get the directory where this script is located
57
- script_dir = os.path.dirname(os.path.abspath(__file__))
58
- base_dir = os.path.dirname(script_dir) # Go up one level to cato-cli directory
59
-
60
- # Find all query.policy*.json files in the models directory
61
- models_dir = os.path.join(base_dir, "models")
62
- pattern = os.path.join(models_dir, "query.policy*.json")
63
-
64
- files = glob.glob(pattern)
65
-
66
- if not files:
67
- print("No query.policy*.json files found!")
68
- return 1
69
-
70
- print(f"Found {len(files)} files to process:")
71
- for file in files:
72
- print(f" - {os.path.basename(file)}")
73
-
74
- # Process each file
75
- success_count = 0
76
- for file_path in files:
77
- if process_file(file_path):
78
- success_count += 1
79
-
80
- print(f"\nProcessing complete!")
81
- print(f"Successfully processed: {success_count}/{len(files)} files")
82
-
83
- if success_count != len(files):
84
- return 1
85
-
86
- return 0
87
-
88
- if __name__ == "__main__":
89
- sys.exit(main())
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
- import json
4
- import os
5
- import glob
6
-
7
- def remove_policy_id_recursive(obj, path=""):
8
- """
9
- Recursively remove all 'policyId' keys from a JSON object.
10
- Returns the number of removals made.
11
- """
12
- removals = 0
13
-
14
- if isinstance(obj, dict):
15
- # Create a list of keys to remove to avoid modifying dict during iteration
16
- keys_to_remove = []
17
- for key in obj.keys():
18
- if key == "policyId":
19
- keys_to_remove.append(key)
20
- current_path = f"{path}.{key}" if path else key
21
- print(f" Removing policyId at: {current_path}")
22
- removals += 1
23
-
24
- # Remove the policyId keys
25
- for key in keys_to_remove:
26
- del obj[key]
27
-
28
- # Recursively process remaining values
29
- for key, value in obj.items():
30
- current_path = f"{path}.{key}" if path else key
31
- removals += remove_policy_id_recursive(value, current_path)
32
-
33
- elif isinstance(obj, list):
34
- for i, item in enumerate(obj):
35
- current_path = f"{path}[{i}]" if path else f"[{i}]"
36
- removals += remove_policy_id_recursive(item, current_path)
37
-
38
- return removals
39
-
40
- def process_mutation_policy_files():
41
- """
42
- Find and process all mutation.policy*.json files in the models directory.
43
- """
44
- models_dir = "/Users/briananderson/Documents/Dev/github.com/catonetworks/cato-cli/models"
45
- pattern = os.path.join(models_dir, "mutation.policy*.json")
46
-
47
- files = glob.glob(pattern)
48
-
49
- if not files:
50
- print("No mutation.policy*.json files found!")
51
- return
52
-
53
- print(f"Found {len(files)} mutation.policy*.json files to process:")
54
-
55
- total_removals = 0
56
- processed_files = 0
57
-
58
- for file_path in sorted(files):
59
- filename = os.path.basename(file_path)
60
- print(f"\nProcessing: {filename}")
61
-
62
- try:
63
- # Read the JSON file
64
- with open(file_path, 'r', encoding='utf-8') as f:
65
- data = json.load(f)
66
-
67
- # Remove policyId fields
68
- removals = remove_policy_id_recursive(data, filename)
69
-
70
- if removals > 0:
71
- # Write back the modified JSON
72
- with open(file_path, 'w', encoding='utf-8') as f:
73
- json.dump(data, f, indent=4, ensure_ascii=False)
74
-
75
- print(f" Removed {removals} policyId field(s)")
76
- total_removals += removals
77
- processed_files += 1
78
- else:
79
- print(" No policyId fields found")
80
-
81
- except Exception as e:
82
- print(f" Error processing {filename}: {e}")
83
-
84
- print(f"\n=== Summary ===")
85
- print(f"Files processed: {processed_files}")
86
- print(f"Total policyId fields removed: {total_removals}")
87
-
88
- if __name__ == "__main__":
89
- process_mutation_policy_files()
@@ -1,62 +0,0 @@
1
- #!/usr/bin/env python3
2
- import json
3
- import os
4
- import sys
5
- import subprocess
6
- from typing import Any, Dict, List, Union
7
-
8
- def should_strip_id(obj: Dict[str, Any]) -> bool:
9
- if not isinstance(obj, dict):
10
- return False
11
-
12
- keys = set(obj.keys())
13
- return keys == {'name', 'id'}
14
-
15
- def strip_ids_recursive(obj: Union[Dict, List, Any]) -> Union[Dict, List, Any, None]:
16
- if isinstance(obj, dict):
17
- new_obj = {}
18
- for key, value in obj.items():
19
- ## Ignoring sections to retain id and name pair
20
- if key == 'sections':
21
- new_obj[key] = value
22
- else:
23
- processed_value = strip_ids_recursive(value)
24
- # Skip keys where the value is an empty list
25
- if processed_value != []:
26
- new_obj[key] = processed_value
27
- # Check if this object should have its id stripped
28
- if should_strip_id(new_obj):
29
- return {'name': new_obj['name']}
30
- return new_obj
31
-
32
- elif isinstance(obj, list):
33
- # Recursively process all items in the list
34
- processed_list = [strip_ids_recursive(item) for item in obj]
35
- # Remove None values from the list (if any were removed)
36
- processed_list = [item for item in processed_list if item is not None]
37
- return processed_list
38
-
39
- else:
40
- # For primitive types (str, int, bool, None), return as-is
41
- return obj
42
-
43
- ## General purpose functions
44
- def exec_cli(command):
45
- result = None
46
- try:
47
- response = subprocess.run(command, shell=True, text=True, capture_output=True)
48
- if response.returncode != 0:
49
- print(f"Command failed with return code {response.returncode}")
50
- print(f"stderr: {response.stderr}")
51
- return None
52
- result = json.loads(response.stdout)
53
- except json.JSONDecodeError as e:
54
- print(f"Failed to parse JSON response: {e}")
55
- print(f"stdout: {response.stdout}")
56
- print(f"stderr: {response.stderr}")
57
- return None
58
- except Exception as e:
59
- print(f"Failed to execute command: {e}")
60
- return None
61
- return result
62
-
@@ -1,188 +0,0 @@
1
- import sys
2
- import csv
3
- import subprocess
4
- import json
5
- import os
6
- import argparse
7
- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
8
- from graphql_client.api.call_api import ApiClient, CallApi
9
- from graphql_client import Configuration
10
- from graphql_client.api_client import ApiException
11
- import catocli
12
-
13
- # Configuration variables
14
- DESTINATION_DIR = "config_data"
15
-
16
- def strip_ids_recursive(data):
17
- """Recursively strip id attributes from data structure"""
18
- if isinstance(data, dict):
19
- return {k: strip_ids_recursive(v) for k, v in data.items() if k != 'id'}
20
- elif isinstance(data, list):
21
- return [strip_ids_recursive(item) for item in data]
22
- else:
23
- return data
24
-
25
- def main():
26
- # Parse command line arguments
27
- parser = argparse.ArgumentParser(description='Export IFW rules to JSON')
28
- parser.add_argument('-accountID', help='Account ID to export rules from', required=True)
29
- parser.add_argument('--output-file-path', help='Full path including filename and extension for output file. If not specified, uses default: config_data/all_ifw_rules_and_sections_{account_id}.json')
30
- parser.add_argument('-v', '--verbose', action='store_true', help='Verbose output')
31
- args = parser.parse_args()
32
-
33
- ACCOUNT_ID = args.accountID
34
-
35
- # Setup API client configuration
36
- if "CATO_TOKEN" not in os.environ:
37
- print("Missing authentication, please set the CATO_TOKEN environment variable with your api key.")
38
- sys.exit(1)
39
-
40
- configuration = Configuration()
41
- configuration.verify_ssl = False
42
- configuration.api_key["x-api-key"] = os.getenv("CATO_TOKEN")
43
- configuration.host = "{}".format(catocli.__cato_host__)
44
- configuration.accountID = ACCOUNT_ID
45
-
46
- # Set up output file path
47
- if args.output_file_path:
48
- # Use output file path if provided
49
- output_file = args.output_file_path
50
- destination_dir = os.path.dirname(output_file)
51
- if args.verbose:
52
- print(f"Using output file path: {output_file}")
53
- else:
54
- # Use default path and filename
55
- destination_dir = 'config_data'
56
- json_output_file = f"all_ifw_rules_and_sections_{ACCOUNT_ID}.json"
57
- output_file = os.path.join(destination_dir, json_output_file)
58
- if args.verbose:
59
- print(f"Using default path: {output_file}")
60
-
61
- # Create destination directory if it doesn't exist
62
- if destination_dir and not os.path.exists(destination_dir):
63
- if args.verbose:
64
- print(f"Creating directory: {destination_dir}")
65
- os.makedirs(destination_dir)
66
- policyQuery = {
67
- "query": "query policy ( $accountId:ID! ) { policy ( accountId:$accountId ) { internetFirewall { policy { enabled rules { audit { updatedTime updatedBy } rule { id name description index section { id name } enabled source { ip host { id name } site { id name } subnet ipRange { from to } globalIpRange { id name } networkInterface { id name } siteNetworkSubnet { id name } floatingSubnet { id name } user { id name } usersGroup { id name } group { id name } systemGroup { id name } } connectionOrigin country { id name } device { id name } deviceOS deviceAttributes { category type model manufacturer os osVersion } destination { application { id name } customApp { id name } appCategory { id name } customCategory { id name } sanctionedAppsCategory { id name } country { id name } domain fqdn ip subnet ipRange { from to } globalIpRange { id name } remoteAsn containers { fqdnContainer { id name } ipAddressRangeContainer { id name } } } service { standard { id name } custom { port portRange { from to } protocol } } action tracking { event { enabled } alert { enabled frequency subscriptionGroup { id name } webhook { id name } mailingList { id name } } } schedule { activeOn customTimeframePolicySchedule: customTimeframe { from to } customRecurringPolicySchedule: customRecurring { from to days } } exceptions { name source { ip host { id name } site { id name } subnet ipRange { from to } globalIpRange { id name } networkInterface { id name } siteNetworkSubnet { id name } floatingSubnet { id name } user { id name } usersGroup { id name } group { id name } systemGroup { id name } } deviceOS country { id name } device { id name } deviceAttributes { category type model manufacturer os osVersion } destination { application { id name } customApp { id name } appCategory { id name } customCategory { id name } sanctionedAppsCategory { id name } country { id name } domain fqdn ip subnet ipRange { from to } globalIpRange { id name } remoteAsn containers { fqdnContainer { id name } ipAddressRangeContainer { id name } } } service { standard { id name } custom { port portRangeCustomService: portRange { from to } protocol } } connectionOrigin } } properties } sections { audit { updatedTime updatedBy } section { id name } properties } audit { publishedTime publishedBy } revision { id name description changes createdTime updatedTime } } } } }",
68
- "variables": {
69
- "accountId": ACCOUNT_ID
70
- },
71
- "operationName": "policy"
72
- }
73
- print(f"Retrieving all IFW rules and sections for account {ACCOUNT_ID}...")
74
-
75
- # Create API client instance
76
- instance = CallApi(ApiClient(configuration))
77
-
78
- # Create params object for the API call
79
- params = {
80
- 'v': False, # verbose mode
81
- 'f': 'json', # format
82
- 'p': False, # pretty print
83
- 't': False # test mode
84
- }
85
-
86
- try:
87
- # Call the API directly
88
- response = instance.call_api(policyQuery, params)
89
- allIfwRules = response[0] if response else {}
90
-
91
- if not allIfwRules or 'data' not in allIfwRules:
92
- print("ERROR: Failed to retrieve data from API")
93
- sys.exit(1)
94
-
95
- except ApiException as e:
96
- print(f"ERROR: API call failed - {e}")
97
- sys.exit(1)
98
- except Exception as e:
99
- print(f"ERROR: Unexpected error - {e}")
100
- sys.exit(1)
101
-
102
- # First, preserve section IDs before stripping them
103
- section_id_map = {}
104
- sections_with_ids = allIfwRules['data']['policy']['internetFirewall']['policy']['sections']
105
- for section_data in sections_with_ids:
106
- section_id_map[section_data['section']['name']] = section_data['section']['id']
107
-
108
- # Get the first section ID for section_to_start_after_id
109
- section_to_start_after_id = None
110
- if len(sections_with_ids) > 0:
111
- section_to_start_after_id = sections_with_ids[0]['section']['id']
112
- print(f"Excluding first section with system rule: {sections_with_ids[0]['section']['name']}")
113
-
114
- ## Processing data to strip id attributes
115
- processed_data = strip_ids_recursive(allIfwRules)
116
-
117
- ## Filter out rules with properties[0]=="SYSTEM"
118
- filtered_rules = []
119
- for rule_data in processed_data['data']['policy']['internetFirewall']['policy']['rules']:
120
- rule_properties = rule_data.get('properties', [])
121
- # Skip rules where the first property is "SYSTEM"
122
- if rule_properties and rule_properties[0] == "SYSTEM":
123
- print(f"Excluding SYSTEM rule: {rule_data['rule']['name']}")
124
- else:
125
- filtered_rules.append(rule_data)
126
- processed_data['data']['policy']['internetFirewall']['policy']['rules'] = filtered_rules
127
- # rules = filtered_rules
128
-
129
- # Add index_in_section to each rule
130
- # Group rules by section and add index_in_section
131
- section_counters = {}
132
- for rule_data in processed_data['data']['policy']['internetFirewall']['policy']['rules']:
133
- section_name = rule_data['rule']['section']['name']
134
- if section_name not in section_counters:
135
- section_counters[section_name] = 0
136
- section_counters[section_name] += 1
137
- rule_data['rule']['index_in_section'] = section_counters[section_name]
138
-
139
- # Create rules_in_sections array
140
- rules_in_sections = []
141
- for rule_data in processed_data['data']['policy']['internetFirewall']['policy']['rules']:
142
- rule_info = rule_data['rule']
143
- rules_in_sections.append({
144
- "index_in_section": rule_info['index_in_section'],
145
- "section_name": rule_info['section']['name'],
146
- "rule_name": rule_info['name']
147
- })
148
- rule_info.pop("index_in_section", None)
149
- rule_info.pop("index", None)
150
- rule_info["enabled"] = True
151
-
152
- # Add rules_in_sections to the policy structure
153
- processed_data['data']['policy']['internetFirewall']['policy']['rules_in_sections'] = rules_in_sections
154
-
155
- # Reformat sections array to have index, section_id and section_name structure
156
- # Exclude the first section from export
157
- processed_sections = []
158
- # Add first section containing reserved SYSTEM rules as section_to_start_after_id
159
- for index, section_data in enumerate(processed_data['data']['policy']['internetFirewall']['policy']['sections']):
160
- if index == 0:
161
- # Skip the first section which contains reserved SYSTEM rules
162
- continue
163
- else:
164
- processed_sections.append({
165
- "section_index": index,
166
- "section_name": section_data['section']['name']
167
- })
168
-
169
- # Add preserved section IDs and section_to_start_after_id
170
- processed_data['data']['policy']['internetFirewall']['policy']['section_ids'] = section_id_map
171
- if section_to_start_after_id:
172
- processed_data['data']['policy']['internetFirewall']['policy']['section_to_start_after_id'] = section_to_start_after_id
173
-
174
- if len(sections_with_ids) > 0:
175
- print(f"Excluded first section: {sections_with_ids[0]['section']['name']} containing reserved SYSTEM rules")
176
-
177
- # Replace the original sections array with the reformatted one
178
- processed_data['data']['policy']['internetFirewall']['policy']['sections'] = processed_sections
179
-
180
- # Write the processed data to the new file
181
- with open(output_file, 'w', encoding='utf-8') as f:
182
- json.dump(processed_data, f, indent=4, ensure_ascii=False)
183
- print(f"Successfully created {output_file}")
184
-
185
-
186
- if __name__ == "__main__":
187
- main()
188
-
@@ -1,111 +0,0 @@
1
- import sys
2
- import csv
3
- import subprocess
4
- import json
5
- import os
6
- import argparse
7
- import catolib
8
-
9
- # Configuration variables
10
- DESTINATION_DIR = "config_data"
11
-
12
- def main():
13
- # Parse command line arguments
14
- parser = argparse.ArgumentParser(description='Export WAN rules to JSON')
15
- parser.add_argument('account_id', help='Account ID to export rules from')
16
- args = parser.parse_args()
17
-
18
- ACCOUNT_ID = args.account_id
19
- JSON_OUTPUT_FILE = f"all_wf_rules_and_sections_{ACCOUNT_ID}.json"
20
- # Create destination directory if it doesn't exist
21
- if not os.path.exists(DESTINATION_DIR):
22
- print(f"Creating directory: {DESTINATION_DIR}")
23
- os.makedirs(DESTINATION_DIR)
24
-
25
- # Set full file paths
26
- output_file = os.path.join(DESTINATION_DIR, JSON_OUTPUT_FILE)
27
- policyQuery = {
28
- "query": "query policy ( $accountId:ID! ) { policy ( accountId:$accountId ) { wanFirewall { policy { enabled rules { audit { updatedTime updatedBy } rule { id name description index section { id name } enabled source { host { id name } site { id name } subnet ip ipRange { from to } globalIpRange { id name } networkInterface { id name } siteNetworkSubnet { id name } floatingSubnet { id name } user { id name } usersGroup { id name } group { id name } systemGroup { id name } } connectionOrigin country { id name } device { id name } deviceOS deviceAttributes { category type model manufacturer os osVersion } destination { host { id name } site { id name } subnet ip ipRange { from to } globalIpRange { id name } networkInterface { id name } siteNetworkSubnet { id name } floatingSubnet { id name } user { id name } usersGroup { id name } group { id name } systemGroup { id name } } application { application { id name } appCategory { id name } customApp { id name } customCategory { id name } sanctionedAppsCategory { id name } domain fqdn ip subnet ipRange { from to } globalIpRange { id name } } service { standard { id name } custom { port portRange { from to } protocol } } action tracking { event { enabled } alert { enabled frequency subscriptionGroup { id name } webhook { id name } mailingList { id name } } } schedule { activeOn customTimeframePolicySchedule: customTimeframe { from to } customRecurringPolicySchedule: customRecurring { from to days } } direction exceptions { name source { host { id name } site { id name } subnet ip ipRange { from to } globalIpRange { id name } networkInterface { id name } siteNetworkSubnet { id name } floatingSubnet { id name } user { id name } usersGroup { id name } group { id name } systemGroup { id name } } deviceOS destination { host { id name } site { id name } subnet ip ipRange { from to } globalIpRange { id name } networkInterface { id name } siteNetworkSubnet { id name } floatingSubnet { id name } user { id name } usersGroup { id name } group { id name } systemGroup { id name } } country { id name } device { id name } deviceAttributes { category type model manufacturer os osVersion } application { application { id name } appCategory { id name } customApp { id name } customCategory { id name } sanctionedAppsCategory { id name } domain fqdn ip subnet ipRange { from to } globalIpRange { id name } } service { standard { id name } custom { port portRangeCustomService: portRange { from to } protocol } } connectionOrigin direction } } properties } sections { audit { updatedTime updatedBy } section { id name } properties } audit { publishedTime publishedBy } revision { id name description changes createdTime updatedTime } } } } }",
29
- "variables": {
30
- "accountId": ACCOUNT_ID
31
- },
32
- "operationName": "policy"
33
- }
34
- catocliCommand = "catocli raw '"+json.dumps(policyQuery)+"'"
35
- print(f"Retrieving all WAN rules and sections for account {ACCOUNT_ID}...")
36
- allWanRules = catolib.exec_cli(catocliCommand)
37
-
38
- ## Processing data to strip id attributes
39
- processed_data = catolib.strip_ids_recursive(allWanRules)
40
-
41
- ## Preserving section IDs index by section name
42
- section_id_map = {}
43
- if 'data' in allWanRules and 'policy' in allWanRules['data'] and 'wanFirewall' in allWanRules['data']['policy']:
44
- for section_data in allWanRules['data']['policy']['wanFirewall']['policy']['sections']:
45
- section_id_map[section_data['section']['name']] = section_data['section']['id']
46
- processed_data['data']['policy']['wanFirewall']['policy']['section_ids'] = section_id_map
47
-
48
- ## Filter out rules with properties[0]=="SYSTEM"
49
- filtered_rules = []
50
- for rule_data in processed_data['data']['policy']['wanFirewall']['policy']['rules']:
51
- rule_properties = rule_data.get('properties', [])
52
- # Skip rules where the first property is "SYSTEM"
53
- if rule_properties and rule_properties[0] == "SYSTEM":
54
- print(f"Excluding SYSTEM rule: {rule_data['rule']['name']}")
55
- else:
56
- filtered_rules.append(rule_data)
57
- processed_data['data']['policy']['wanFirewall']['policy']['rules'] = filtered_rules
58
- # rules = filtered_rules
59
-
60
- # Add index_in_section to each rule
61
- # Group rules by section and add index_in_section
62
- section_counters = {}
63
- for rule_data in processed_data['data']['policy']['wanFirewall']['policy']['rules']:
64
- section_name = rule_data['rule']['section']['name']
65
- if section_name not in section_counters:
66
- section_counters[section_name] = 0
67
- section_counters[section_name] += 1
68
- rule_data['rule']['index_in_section'] = section_counters[section_name]
69
-
70
- # Create rules_in_sections array
71
- rules_in_sections = []
72
- for rule_data in processed_data['data']['policy']['wanFirewall']['policy']['rules']:
73
- rule_info = rule_data['rule']
74
- rules_in_sections.append({
75
- "index_in_section": rule_info['index_in_section'],
76
- "section_name": rule_info['section']['name'],
77
- "rule_name": rule_info['name']
78
- })
79
- rule_info.pop("index_in_section", None)
80
- rule_info.pop("index", None)
81
- rule_info["enabled"] = True
82
-
83
- # Add rules_in_sections to the policy structure
84
- processed_data['data']['policy']['wanFirewall']['policy']['rules_in_sections'] = rules_in_sections
85
-
86
- # Reformat sections array to have index, section_id and section_name structure
87
- # Exclude the first section from export, excluding first section
88
-
89
- processed_sections = []
90
- # Add first section containing reserved SYSTEM rules as section_to_start_after_id
91
- for index, section_data in enumerate(processed_data['data']['policy']['wanFirewall']['policy']['sections']):
92
- processed_sections.append({
93
- "section_index": index,
94
- "section_name": section_data['section']['name']
95
- })
96
-
97
- if len(processed_data['data']['policy']['wanFirewall']['policy']['sections']) > 0:
98
- print(f"Excluded first section: {processed_data['data']['policy']['wanFirewall']['policy']['sections'][0]['section']['name']} containing reserved SYSTEM rules")
99
-
100
- # Replace the original sections array with the reformatted one
101
- processed_data['data']['policy']['wanFirewall']['policy']['sections'] = processed_sections
102
-
103
- # Write the processed data to the new file
104
- with open(output_file, 'w', encoding='utf-8') as f:
105
- json.dump(processed_data, f, indent=4, ensure_ascii=False)
106
- print(f"Successfully created {output_file}")
107
-
108
-
109
- if __name__ == "__main__":
110
- main()
111
-