catocli 2.0.4__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 (300) hide show
  1. catocli/Utils/clidriver.py +11 -4
  2. catocli/__init__.py +1 -1
  3. catocli/parsers/custom/export_sites/export_sites.py +20 -3
  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_container/__init__.py +116 -0
  9. catocli/parsers/mutation_container_fqdn/README.md +7 -0
  10. catocli/parsers/mutation_container_fqdn_addValues/README.md +17 -0
  11. catocli/parsers/mutation_container_fqdn_createFromFile/README.md +17 -0
  12. catocli/parsers/mutation_container_fqdn_removeValues/README.md +17 -0
  13. catocli/parsers/mutation_container_fqdn_updateFromFile/README.md +17 -0
  14. catocli/parsers/mutation_container_ipAddressRange/README.md +7 -0
  15. catocli/parsers/mutation_container_ipAddressRange_addValues/README.md +17 -0
  16. catocli/parsers/mutation_container_ipAddressRange_createFromFile/README.md +17 -0
  17. catocli/parsers/mutation_container_ipAddressRange_removeValues/README.md +17 -0
  18. catocli/parsers/mutation_container_ipAddressRange_updateFromFile/README.md +17 -0
  19. catocli/parsers/mutation_groups/README.md +7 -0
  20. catocli/parsers/mutation_groups/__init__.py +48 -0
  21. catocli/parsers/mutation_groups_createGroup/README.md +18 -0
  22. catocli/parsers/mutation_groups_deleteGroup/README.md +18 -0
  23. catocli/parsers/mutation_groups_updateGroup/README.md +18 -0
  24. catocli/parsers/mutation_policy_internetFirewall_addRule/README.md +1 -1
  25. catocli/parsers/mutation_policy_internetFirewall_updateRule/README.md +1 -1
  26. catocli/parsers/mutation_policy_wanFirewall_addRule/README.md +1 -1
  27. catocli/parsers/mutation_policy_wanFirewall_updateRule/README.md +1 -1
  28. catocli/parsers/mutation_site/__init__.py +104 -0
  29. catocli/parsers/mutation_site_assignSiteBwLicense/README.md +17 -0
  30. catocli/parsers/mutation_site_removeSecondaryAwsVSocket/README.md +17 -0
  31. catocli/parsers/mutation_site_removeSecondaryAzureVSocket/README.md +17 -0
  32. catocli/parsers/mutation_site_removeSiteBwLicense/README.md +17 -0
  33. catocli/parsers/mutation_site_replaceSiteBwLicense/README.md +17 -0
  34. catocli/parsers/mutation_site_updateSecondaryAwsVSocket/README.md +17 -0
  35. catocli/parsers/mutation_site_updateSecondaryAzureVSocket/README.md +17 -0
  36. catocli/parsers/mutation_site_updateSiteBwLicense/README.md +17 -0
  37. catocli/parsers/mutation_site_updateSiteGeneralDetails/README.md +1 -1
  38. catocli/parsers/mutation_sites/__init__.py +104 -0
  39. catocli/parsers/mutation_sites_assignSiteBwLicense/README.md +17 -0
  40. catocli/parsers/mutation_sites_removeSecondaryAwsVSocket/README.md +17 -0
  41. catocli/parsers/mutation_sites_removeSecondaryAzureVSocket/README.md +17 -0
  42. catocli/parsers/mutation_sites_removeSiteBwLicense/README.md +17 -0
  43. catocli/parsers/mutation_sites_replaceSiteBwLicense/README.md +17 -0
  44. catocli/parsers/mutation_sites_updateSecondaryAwsVSocket/README.md +17 -0
  45. catocli/parsers/mutation_sites_updateSecondaryAzureVSocket/README.md +17 -0
  46. catocli/parsers/mutation_sites_updateSiteBwLicense/README.md +17 -0
  47. catocli/parsers/mutation_sites_updateSiteGeneralDetails/README.md +1 -1
  48. catocli/parsers/parserApiClient.py +42 -19
  49. catocli/parsers/query_eventsFeed/README.md +1 -1
  50. catocli/parsers/query_groups/README.md +7 -0
  51. catocli/parsers/query_groups/__init__.py +54 -0
  52. catocli/parsers/query_groups_group/README.md +7 -0
  53. catocli/parsers/query_groups_groupList/README.md +18 -0
  54. catocli/parsers/query_groups_group_members/README.md +18 -0
  55. catocli/parsers/query_groups_whereUsed/README.md +17 -0
  56. catocli/parsers/query_policy/README.md +0 -17
  57. catocli/parsers/query_policy/__init__.py +153 -8
  58. catocli/parsers/query_policy_appTenantRestriction/README.md +7 -0
  59. catocli/parsers/query_policy_appTenantRestriction_policy/README.md +17 -0
  60. catocli/parsers/query_policy_dynamicIpAllocation/README.md +7 -0
  61. catocli/parsers/query_policy_dynamicIpAllocation_policy/README.md +17 -0
  62. catocli/parsers/query_policy_internetFirewall/README.md +7 -0
  63. catocli/parsers/query_policy_internetFirewall_policy/README.md +17 -0
  64. catocli/parsers/query_policy_remotePortFwd/README.md +7 -0
  65. catocli/parsers/query_policy_remotePortFwd_policy/README.md +17 -0
  66. catocli/parsers/query_policy_socketLan/README.md +7 -0
  67. catocli/parsers/query_policy_socketLan_policy/README.md +17 -0
  68. catocli/parsers/query_policy_terminalServer/README.md +7 -0
  69. catocli/parsers/query_policy_terminalServer_policy/README.md +17 -0
  70. catocli/parsers/query_policy_wanFirewall/README.md +7 -0
  71. catocli/parsers/query_policy_wanFirewall_policy/README.md +17 -0
  72. catocli/parsers/query_policy_wanNetwork/README.md +7 -0
  73. catocli/parsers/query_policy_wanNetwork_policy/README.md +17 -0
  74. catocli/parsers/query_popLocations/README.md +17 -0
  75. catocli/parsers/query_popLocations/__init__.py +16 -0
  76. catocli/parsers/query_site/README.md +0 -16
  77. catocli/parsers/query_site/__init__.py +118 -8
  78. catocli/parsers/query_site_availableVersionList/README.md +17 -0
  79. catocli/parsers/query_site_bgpPeer/README.md +17 -0
  80. catocli/parsers/query_site_bgpPeerList/README.md +17 -0
  81. catocli/parsers/query_site_cloudInterconnectConnectionConnectivity/README.md +17 -0
  82. catocli/parsers/query_site_cloudInterconnectPhysicalConnection/README.md +17 -0
  83. catocli/parsers/query_site_cloudInterconnectPhysicalConnectionId/README.md +17 -0
  84. catocli/parsers/query_site_secondaryAwsVSocket/README.md +17 -0
  85. catocli/parsers/query_site_secondaryAzureVSocket/README.md +17 -0
  86. catocli/parsers/query_site_siteBgpStatus/README.md +17 -0
  87. catocli/parsers/query_socketPortMetrics/README.md +23 -0
  88. catocli/parsers/query_socketPortMetrics/__init__.py +16 -0
  89. catocli/parsers/query_socketPortMetricsTimeSeries/README.md +24 -0
  90. catocli/parsers/query_socketPortMetricsTimeSeries/__init__.py +16 -0
  91. catocli/parsers/raw/README.md +0 -14
  92. catocli/parsers/raw/__init__.py +0 -2
  93. {catocli-2.0.4.dist-info → catocli-2.1.0.dist-info}/METADATA +3 -2
  94. {catocli-2.0.4.dist-info → catocli-2.1.0.dist-info}/RECORD +300 -178
  95. {catocli-2.0.4.dist-info → catocli-2.1.0.dist-info}/WHEEL +1 -1
  96. {catocli-2.0.4.dist-info → catocli-2.1.0.dist-info}/top_level.txt +0 -1
  97. graphql_client/api/call_api.py +4 -3
  98. models/mutation.accountManagement.addAccount.json +97 -0
  99. models/mutation.accountManagement.disableAccount.json +545 -0
  100. models/mutation.accountManagement.removeAccount.json +102 -3
  101. models/mutation.accountManagement.updateAccount.json +97 -0
  102. models/mutation.admin.addAdmin.json +6 -9
  103. models/mutation.container.delete.json +2 -2
  104. models/mutation.container.fqdn.addValues.json +866 -0
  105. models/mutation.container.fqdn.createFromFile.json +819 -0
  106. models/mutation.container.fqdn.removeValues.json +866 -0
  107. models/mutation.container.fqdn.updateFromFile.json +1045 -0
  108. models/mutation.container.ipAddressRange.addValues.json +1020 -0
  109. models/mutation.container.ipAddressRange.createFromFile.json +819 -0
  110. models/mutation.container.ipAddressRange.removeValues.json +1020 -0
  111. models/mutation.container.ipAddressRange.updateFromFile.json +1045 -0
  112. models/mutation.groups.createGroup.json +3178 -0
  113. models/mutation.groups.deleteGroup.json +2758 -0
  114. models/mutation.groups.updateGroup.json +4429 -0
  115. models/mutation.hardware.updateHardwareShipping.json +30 -10
  116. models/mutation.policy.appTenantRestriction.addRule.json +25 -25
  117. models/mutation.policy.appTenantRestriction.addSection.json +3 -3
  118. models/mutation.policy.appTenantRestriction.createPolicyRevision.json +31 -31
  119. models/mutation.policy.appTenantRestriction.discardPolicyRevision.json +31 -31
  120. models/mutation.policy.appTenantRestriction.moveRule.json +25 -25
  121. models/mutation.policy.appTenantRestriction.moveSection.json +3 -3
  122. models/mutation.policy.appTenantRestriction.publishPolicyRevision.json +31 -31
  123. models/mutation.policy.appTenantRestriction.removeRule.json +25 -25
  124. models/mutation.policy.appTenantRestriction.removeSection.json +3 -3
  125. models/mutation.policy.appTenantRestriction.updatePolicy.json +31 -31
  126. models/mutation.policy.appTenantRestriction.updateRule.json +25 -25
  127. models/mutation.policy.appTenantRestriction.updateSection.json +3 -3
  128. models/mutation.policy.dynamicIpAllocation.addRule.json +11 -11
  129. models/mutation.policy.dynamicIpAllocation.addSection.json +3 -3
  130. models/mutation.policy.dynamicIpAllocation.createPolicyRevision.json +17 -17
  131. models/mutation.policy.dynamicIpAllocation.discardPolicyRevision.json +17 -17
  132. models/mutation.policy.dynamicIpAllocation.moveRule.json +11 -11
  133. models/mutation.policy.dynamicIpAllocation.moveSection.json +3 -3
  134. models/mutation.policy.dynamicIpAllocation.publishPolicyRevision.json +17 -17
  135. models/mutation.policy.dynamicIpAllocation.removeRule.json +11 -11
  136. models/mutation.policy.dynamicIpAllocation.removeSection.json +3 -3
  137. models/mutation.policy.dynamicIpAllocation.updatePolicy.json +17 -17
  138. models/mutation.policy.dynamicIpAllocation.updateRule.json +11 -11
  139. models/mutation.policy.dynamicIpAllocation.updateSection.json +3 -3
  140. models/mutation.policy.internetFirewall.addRule.json +532 -85
  141. models/mutation.policy.internetFirewall.addSection.json +3 -3
  142. models/mutation.policy.internetFirewall.createPolicyRevision.json +208 -91
  143. models/mutation.policy.internetFirewall.discardPolicyRevision.json +208 -91
  144. models/mutation.policy.internetFirewall.moveRule.json +202 -85
  145. models/mutation.policy.internetFirewall.moveSection.json +3 -3
  146. models/mutation.policy.internetFirewall.publishPolicyRevision.json +208 -91
  147. models/mutation.policy.internetFirewall.removeRule.json +202 -85
  148. models/mutation.policy.internetFirewall.removeSection.json +3 -3
  149. models/mutation.policy.internetFirewall.updatePolicy.json +208 -91
  150. models/mutation.policy.internetFirewall.updateRule.json +523 -85
  151. models/mutation.policy.internetFirewall.updateSection.json +3 -3
  152. models/mutation.policy.remotePortFwd.addRule.json +16 -16
  153. models/mutation.policy.remotePortFwd.addSection.json +3 -3
  154. models/mutation.policy.remotePortFwd.createPolicyRevision.json +22 -22
  155. models/mutation.policy.remotePortFwd.discardPolicyRevision.json +22 -22
  156. models/mutation.policy.remotePortFwd.moveRule.json +16 -16
  157. models/mutation.policy.remotePortFwd.moveSection.json +3 -3
  158. models/mutation.policy.remotePortFwd.publishPolicyRevision.json +22 -22
  159. models/mutation.policy.remotePortFwd.removeRule.json +16 -16
  160. models/mutation.policy.remotePortFwd.removeSection.json +3 -3
  161. models/mutation.policy.remotePortFwd.updatePolicy.json +22 -22
  162. models/mutation.policy.remotePortFwd.updateRule.json +16 -16
  163. models/mutation.policy.remotePortFwd.updateSection.json +3 -3
  164. models/mutation.policy.socketLan.addRule.json +81 -81
  165. models/mutation.policy.socketLan.addSection.json +3 -3
  166. models/mutation.policy.socketLan.createPolicyRevision.json +87 -87
  167. models/mutation.policy.socketLan.discardPolicyRevision.json +87 -87
  168. models/mutation.policy.socketLan.moveRule.json +81 -81
  169. models/mutation.policy.socketLan.moveSection.json +3 -3
  170. models/mutation.policy.socketLan.publishPolicyRevision.json +87 -87
  171. models/mutation.policy.socketLan.removeRule.json +81 -81
  172. models/mutation.policy.socketLan.removeSection.json +3 -3
  173. models/mutation.policy.socketLan.updatePolicy.json +87 -87
  174. models/mutation.policy.socketLan.updateRule.json +81 -81
  175. models/mutation.policy.socketLan.updateSection.json +3 -3
  176. models/mutation.policy.terminalServer.addRule.json +6 -6
  177. models/mutation.policy.terminalServer.addSection.json +3 -3
  178. models/mutation.policy.terminalServer.createPolicyRevision.json +12 -12
  179. models/mutation.policy.terminalServer.discardPolicyRevision.json +12 -12
  180. models/mutation.policy.terminalServer.moveRule.json +6 -6
  181. models/mutation.policy.terminalServer.moveSection.json +3 -3
  182. models/mutation.policy.terminalServer.publishPolicyRevision.json +12 -12
  183. models/mutation.policy.terminalServer.removeRule.json +6 -6
  184. models/mutation.policy.terminalServer.removeSection.json +3 -3
  185. models/mutation.policy.terminalServer.updatePolicy.json +12 -12
  186. models/mutation.policy.terminalServer.updateRule.json +6 -6
  187. models/mutation.policy.terminalServer.updateSection.json +3 -3
  188. models/mutation.policy.wanFirewall.addRule.json +550 -103
  189. models/mutation.policy.wanFirewall.addSection.json +3 -3
  190. models/mutation.policy.wanFirewall.createPolicyRevision.json +226 -109
  191. models/mutation.policy.wanFirewall.discardPolicyRevision.json +226 -109
  192. models/mutation.policy.wanFirewall.moveRule.json +220 -103
  193. models/mutation.policy.wanFirewall.moveSection.json +3 -3
  194. models/mutation.policy.wanFirewall.publishPolicyRevision.json +226 -109
  195. models/mutation.policy.wanFirewall.removeRule.json +220 -103
  196. models/mutation.policy.wanFirewall.removeSection.json +3 -3
  197. models/mutation.policy.wanFirewall.updatePolicy.json +226 -109
  198. models/mutation.policy.wanFirewall.updateRule.json +541 -103
  199. models/mutation.policy.wanFirewall.updateSection.json +3 -3
  200. models/mutation.policy.wanNetwork.addRule.json +90 -90
  201. models/mutation.policy.wanNetwork.addSection.json +3 -3
  202. models/mutation.policy.wanNetwork.createPolicyRevision.json +96 -96
  203. models/mutation.policy.wanNetwork.discardPolicyRevision.json +96 -96
  204. models/mutation.policy.wanNetwork.moveRule.json +90 -90
  205. models/mutation.policy.wanNetwork.moveSection.json +3 -3
  206. models/mutation.policy.wanNetwork.publishPolicyRevision.json +96 -96
  207. models/mutation.policy.wanNetwork.removeRule.json +90 -90
  208. models/mutation.policy.wanNetwork.removeSection.json +3 -3
  209. models/mutation.policy.wanNetwork.updatePolicy.json +96 -96
  210. models/mutation.policy.wanNetwork.updateRule.json +90 -90
  211. models/mutation.policy.wanNetwork.updateSection.json +3 -3
  212. models/mutation.site.addBgpPeer.json +10 -10
  213. models/mutation.site.addIpsecIkeV2SiteTunnels.json +2 -2
  214. models/mutation.site.addSocketAddOnCard.json +2 -2
  215. models/mutation.site.assignSiteBwLicense.json +12879 -0
  216. models/mutation.site.removeBgpPeer.json +10 -10
  217. models/mutation.site.removeIpsecIkeV2SiteTunnels.json +2 -2
  218. models/mutation.site.removeSecondaryAwsVSocket.json +375 -0
  219. models/mutation.site.removeSecondaryAzureVSocket.json +354 -0
  220. models/mutation.site.removeSiteBwLicense.json +12822 -0
  221. models/mutation.site.removeSocketAddOnCard.json +2 -2
  222. models/mutation.site.replaceSiteBwLicense.json +12939 -0
  223. models/mutation.site.startSiteUpgrade.json +36 -15
  224. models/mutation.site.updateBgpPeer.json +10 -10
  225. models/mutation.site.updateIpsecIkeV2SiteTunnels.json +2 -2
  226. models/mutation.site.updateSecondaryAwsVSocket.json +643 -0
  227. models/mutation.site.updateSecondaryAzureVSocket.json +565 -0
  228. models/mutation.site.updateSiteBwLicense.json +12882 -0
  229. models/mutation.site.updateSiteGeneralDetails.json +724 -1
  230. models/mutation.sites.addBgpPeer.json +10 -10
  231. models/mutation.sites.addIpsecIkeV2SiteTunnels.json +2 -2
  232. models/mutation.sites.addSocketAddOnCard.json +2 -2
  233. models/mutation.sites.assignSiteBwLicense.json +12879 -0
  234. models/mutation.sites.removeBgpPeer.json +10 -10
  235. models/mutation.sites.removeIpsecIkeV2SiteTunnels.json +2 -2
  236. models/mutation.sites.removeSecondaryAwsVSocket.json +375 -0
  237. models/mutation.sites.removeSecondaryAzureVSocket.json +354 -0
  238. models/mutation.sites.removeSiteBwLicense.json +12822 -0
  239. models/mutation.sites.removeSocketAddOnCard.json +2 -2
  240. models/mutation.sites.replaceSiteBwLicense.json +12939 -0
  241. models/mutation.sites.startSiteUpgrade.json +36 -15
  242. models/mutation.sites.updateBgpPeer.json +10 -10
  243. models/mutation.sites.updateIpsecIkeV2SiteTunnels.json +2 -2
  244. models/mutation.sites.updateSecondaryAwsVSocket.json +643 -0
  245. models/mutation.sites.updateSecondaryAzureVSocket.json +565 -0
  246. models/mutation.sites.updateSiteBwLicense.json +12882 -0
  247. models/mutation.sites.updateSiteGeneralDetails.json +724 -1
  248. models/mutation.xdr.addStoryComment.json +1 -1
  249. models/mutation.xdr.analystFeedback.json +84 -84
  250. models/mutation.xdr.deleteStoryComment.json +1 -1
  251. models/query.accountManagement.json +97 -0
  252. models/query.accountMetrics.json +45 -45
  253. models/query.accountSnapshot.json +30 -30
  254. models/query.admin.json +6 -6
  255. models/query.admins.json +13 -13
  256. models/query.appStats.json +915 -867
  257. models/query.appStatsTimeSeries.json +692 -656
  258. models/query.auditFeed.json +6 -6
  259. models/query.catalogs.json +52 -52
  260. models/query.container.json +16 -16
  261. models/query.devices.json +20 -93
  262. models/query.entityLookup.json +2 -2
  263. models/query.events.json +288 -384
  264. models/query.eventsFeed.json +73 -97
  265. models/query.eventsTimeSeries.json +219 -291
  266. models/query.groups.group.members.json +3058 -0
  267. models/query.groups.groupList.json +6474 -0
  268. models/query.groups.whereUsed.json +697 -0
  269. models/query.hardware.json +27 -7
  270. models/query.hardwareManagement.json +8 -8
  271. models/query.licensing.json +3487 -1324
  272. models/query.policy.appTenantRestriction.policy.json +3086 -0
  273. models/query.policy.dynamicIpAllocation.policy.json +1934 -0
  274. models/query.policy.internetFirewall.policy.json +7833 -0
  275. models/query.policy.json +233 -0
  276. models/query.policy.remotePortFwd.policy.json +2387 -0
  277. models/query.policy.socketLan.policy.json +7140 -0
  278. models/query.policy.terminalServer.policy.json +1632 -0
  279. models/query.policy.wanFirewall.policy.json +9212 -0
  280. models/query.policy.wanNetwork.policy.json +8010 -0
  281. models/query.popLocations.json +2878 -0
  282. models/query.sandbox.json +5 -5
  283. models/query.site.availableVersionList.json +365 -0
  284. models/query.site.bgpPeer.json +1917 -0
  285. models/query.site.bgpPeerList.json +2076 -0
  286. models/query.site.cloudInterconnectConnectionConnectivity.json +298 -0
  287. models/query.site.cloudInterconnectPhysicalConnection.json +728 -0
  288. models/query.site.cloudInterconnectPhysicalConnectionId.json +660 -0
  289. models/query.site.secondaryAwsVSocket.json +340 -0
  290. models/query.site.secondaryAzureVSocket.json +319 -0
  291. models/query.site.siteBgpStatus.json +869 -0
  292. models/query.socketPortMetrics.json +2410 -0
  293. models/query.socketPortMetricsTimeSeries.json +2361 -0
  294. models/query.xdr.stories.json +104 -104
  295. models/query.xdr.story.json +93 -93
  296. schema/catolib.py +34 -18
  297. schema/remove_policyid.py +89 -0
  298. schema/remove_policyid_mutations.py +89 -0
  299. {catocli-2.0.4.dist-info → catocli-2.1.0.dist-info}/entry_points.txt +0 -0
  300. {catocli-2.0.4.dist-info → catocli-2.1.0.dist-info/licenses}/LICENSE +0 -0
schema/catolib.py CHANGED
@@ -78,6 +78,11 @@ def openFile(fileName, readMode="rt"):
78
78
  ############ parsing schema ############
79
79
 
80
80
  def parseSchema(schema):
81
+ # Load settings to get childOperationParent and childOperationObjects configuration
82
+ settings = loadJSON("../settings.json")
83
+ childOperationParent = settings.get("childOperationParent", {})
84
+ childOperationObjects = settings.get("childOperationObjects", {})
85
+
81
86
  mutationOperationsTMP = {}
82
87
  queryOperationsTMP = {}
83
88
  for i, type in enumerate(schema["data"]["__schema"]["types"]):
@@ -94,7 +99,7 @@ def parseSchema(schema):
94
99
  elif type["kind"] == "OBJECT":
95
100
  if type["name"] == "Query":
96
101
  for field in type["fields"]:
97
- if field["name"] =="xdr":
102
+ if field["name"] in childOperationParent:
98
103
  queryOperationsTMP[field["name"]] = copy.deepcopy(field)
99
104
  else:
100
105
  catoApiSchema["query"]["query."+field["name"]] = copy.deepcopy(field)
@@ -107,11 +112,11 @@ def parseSchema(schema):
107
112
 
108
113
  for queryType in queryOperationsTMP:
109
114
  parentQueryOperationType = copy.deepcopy(queryOperationsTMP[queryType])
110
- getChildOperations("query", parentQueryOperationType, parentQueryOperationType, "query." + queryType)
115
+ getChildOperations("query", parentQueryOperationType, parentQueryOperationType, "query." + queryType, childOperationObjects)
111
116
 
112
117
  for mutationType in mutationOperationsTMP:
113
118
  parentMutationOperationType = copy.deepcopy(mutationOperationsTMP[mutationType])
114
- getChildOperations("mutation", parentMutationOperationType, parentMutationOperationType, "mutation." + mutationType)
119
+ getChildOperations("mutation", parentMutationOperationType, parentMutationOperationType, "mutation." + mutationType, childOperationObjects)
115
120
 
116
121
  for operationType in catoApiSchema:
117
122
  for operationName in catoApiSchema[operationType]:
@@ -129,7 +134,7 @@ def parseSchema(schema):
129
134
  payload = generateGraphqlPayload(parsedOperation["variablesPayload"],parsedOperation,operationName)
130
135
  writeFile("../queryPayloads/"+operationName+".txt",payload["query"])
131
136
 
132
- def getChildOperations(operationType, curType, parentType, parentPath):
137
+ def getChildOperations(operationType, curType, parentType, parentPath, childOperationObjects):
133
138
  # Parse fields for nested args to map out all child operations
134
139
  # This will separate fields like stories and story for query.xdr,
135
140
  # and all fields which are actually sub operations from mutation.internetFirewall, etc
@@ -154,12 +159,14 @@ def getChildOperations(operationType, curType, parentType, parentPath):
154
159
  parentFields = []
155
160
  for field in curOfType["fields"]:
156
161
  curFieldObject = copy.deepcopy(field)
157
- if "args" in curFieldObject and len(curFieldObject["args"])>0:
162
+ if (("args" in curFieldObject and len(curFieldObject["args"])>0) or
163
+ (curFieldObject["name"] in childOperationObjects) or
164
+ (curOfType["name"] in childOperationObjects)):
158
165
  hasChildren = True
159
166
  curParentType = copy.deepcopy(parentType)
160
167
  curFieldObject["args"] = getNestedArgDefinitions(curFieldObject["args"], curFieldObject["name"],None,None)
161
168
  curParentType["childOperations"][curFieldObject["name"]] = curFieldObject
162
- getChildOperations(operationType, curFieldObject, curParentType, parentPath + "." + curFieldObject["name"])
169
+ getChildOperations(operationType, curFieldObject, curParentType, parentPath + "." + curFieldObject["name"], childOperationObjects)
163
170
  if not hasChildren:
164
171
  catoApiSchema[operationType][parentPath] = parentType
165
172
 
@@ -193,7 +200,7 @@ def getNestedArgDefinitions(argsAry, parentParamPath, childOperations, parentFie
193
200
  # print("getNestedArgDefinitions()",newArgsList.keys())
194
201
  return newArgsList
195
202
 
196
- def getOfType(curType, ofType, parentParamPath, childOperations, parentFields):
203
+ def getOfType(curType, ofType, parentParamPath, childOperations, parentFields, parentTypeName=None):
197
204
  ofType["kind"].append(copy.deepcopy(curType["kind"]))
198
205
  curParamPath = "" if (parentParamPath == None) else parentParamPath + "___"
199
206
  if curType["ofType"] != None:
@@ -209,7 +216,7 @@ def getOfType(curType, ofType, parentParamPath, childOperations, parentFields):
209
216
  ofType["indexType"] = "input_object"
210
217
  ofType["definition"] = copy.deepcopy(catoApiIntrospection["input_objects"][ofType["name"]])
211
218
  if ofType["definition"]["inputFields"] != None:
212
- ofType["definition"]["inputFields"] = getNestedFieldDefinitions(copy.deepcopy(ofType["definition"]["inputFields"]), curParamPath, childOperations, parentFields)
219
+ ofType["definition"]["inputFields"] = getNestedFieldDefinitions(copy.deepcopy(ofType["definition"]["inputFields"]), curParamPath, childOperations, parentFields, ofType["name"])
213
220
  elif "UNION" in ofType["kind"]:
214
221
  ofType["indexType"] = "interface"
215
222
  ofType["definition"] = copy.deepcopy(catoApiIntrospection["unions"][ofType["name"]])
@@ -236,14 +243,14 @@ def getOfType(curType, ofType, parentParamPath, childOperations, parentFields):
236
243
  ofType["definition"] = copy.deepcopy(catoApiIntrospection["objects"][ofType["name"]])
237
244
  if ofType["definition"]["fields"] != None and childOperations!=None:
238
245
  ofType["definition"]["fields"] = checkForChildOperation(copy.deepcopy(ofType["definition"]["fields"]),childOperations)
239
- ofType["definition"]["fields"] = getNestedFieldDefinitions(copy.deepcopy(ofType["definition"]["fields"]), curParamPath,childOperations, parentFields)
246
+ ofType["definition"]["fields"] = getNestedFieldDefinitions(copy.deepcopy(ofType["definition"]["fields"]), curParamPath,childOperations, parentFields, ofType["name"])
240
247
  if ofType["definition"]["interfaces"] != None:
241
248
  ofType["definition"]["interfaces"] = getNestedInterfaceDefinitions(copy.deepcopy(ofType["definition"]["interfaces"]), curParamPath,childOperations, parentFields)
242
249
  elif "INTERFACE" in ofType["kind"]:
243
250
  ofType["indexType"] = "interface"
244
251
  ofType["definition"] = copy.deepcopy(catoApiIntrospection["interfaces"][ofType["name"]])
245
252
  if ofType["definition"]["fields"] != None:
246
- ofType["definition"]["fields"] = getNestedFieldDefinitions(copy.deepcopy(ofType["definition"]["fields"]), curParamPath, childOperations, parentFields)
253
+ ofType["definition"]["fields"] = getNestedFieldDefinitions(copy.deepcopy(ofType["definition"]["fields"]), curParamPath, childOperations, parentFields, ofType["name"])
247
254
  if ofType["definition"]["possibleTypes"] != None:
248
255
  ofType["definition"]["possibleTypes"] = getNestedInterfaceDefinitions(copy.deepcopy(ofType["definition"]["possibleTypes"]), curParamPath, childOperations, parentFields)
249
256
  for interfaceName in ofType["definition"]["possibleTypes"]:
@@ -270,14 +277,14 @@ def getOfType(curType, ofType, parentParamPath, childOperations, parentFields):
270
277
  ofType["definition"] = copy.deepcopy(catoApiIntrospection["enums"][ofType["name"]])
271
278
  return ofType
272
279
 
273
- def getNestedFieldDefinitions(fieldsAry, parentParamPath,childOperations, parentFields):
280
+ def getNestedFieldDefinitions(fieldsAry, parentParamPath,childOperations, parentFields, parentTypeName=None):
274
281
  newFieldsList = {}
275
282
  for field in fieldsAry:
276
283
  if isinstance(field,str):
277
284
  field = fieldsAry[field]
278
285
  curParamPath = field["name"] if (parentParamPath == None) else (parentParamPath.replace("___",".") + field["name"])
279
286
  # curParamPath = field["name"] if (parentParamPath == None) else (parentParamPath + "." + field["name"])
280
- field["type"] = getOfType(field["type"], { "non_null": False, "kind": [], "name": None }, curParamPath,childOperations, parentFields)
287
+ field["type"] = getOfType(field["type"], { "non_null": False, "kind": [], "name": None }, curParamPath,childOperations, parentFields, parentTypeName)
281
288
  field["path"] = curParamPath
282
289
  field["id_str"] = curParamPath.replace(".","___")
283
290
  if isinstance(field["type"]["kind"], list):
@@ -305,7 +312,11 @@ def getNestedFieldDefinitions(fieldsAry, parentParamPath,childOperations, parent
305
312
  # print(json.dumps(field,indent=2,sort_keys=True))
306
313
  # print(field["path"],parentFields)
307
314
  # field["alias"] = renderCamelCase(field["type"]["name"]+"."+field["name"])+": "+field["name"]
308
- field["alias"] = renderCamelCase(field["type"]["name"]+"."+field["name"])+": "+field["name"]
315
+ # Use parent type name instead of field type name for alias
316
+ if parentTypeName:
317
+ field["alias"] = renderCamelCase(field["name"]+"."+parentTypeName)+": "+field["name"]
318
+ else:
319
+ field["alias"] = renderCamelCase(field["type"]["name"]+"."+field["name"])+": "+field["name"]
309
320
  if "records.fields" not in field["path"]:
310
321
  newFieldsList[field["name"]] = field
311
322
  # for (fieldPath in newFieldList) {
@@ -326,9 +337,9 @@ def getNestedInterfaceDefinitions(possibleTypesAry, parentParamPath,childOperati
326
337
  curInterface = curInterfaces[curInterfaceName]
327
338
  curParamPath = "" if parentParamPath == None else parentParamPath + curInterface["name"] + "___"
328
339
  if "fields" in curInterface and curInterface["fields"] != None:
329
- curInterface["fields"] = getNestedFieldDefinitions(copy.deepcopy(curInterface["fields"]), curParamPath,childOperations, parentFields)
340
+ curInterface["fields"] = getNestedFieldDefinitions(copy.deepcopy(curInterface["fields"]), curParamPath,childOperations, parentFields, curInterface["name"])
330
341
  if "inputFields" in curInterface and curInterface["inputFields"] != None:
331
- curInterface["inputFields"] = getNestedFieldDefinitions(copy.deepcopy(curInterface["inputFields"]), curParamPath,childOperations, parentFields)
342
+ curInterface["inputFields"] = getNestedFieldDefinitions(copy.deepcopy(curInterface["inputFields"]), curParamPath,childOperations, parentFields, curInterface["name"])
332
343
  if "interfaces" in curInterface and curInterface["interfaces"] != None:
333
344
  curInterface["interfaces"] = getNestedInterfaceDefinitions(copy.deepcopy(curInterface["interfaces"]), curParamPath,childOperations, parentFields)
334
345
  if "possibleTypes" in curInterface and curInterface["possibleTypes"] != None:
@@ -350,10 +361,10 @@ def parseOperation(curOperation,childOperations):
350
361
  # for field in curOperation["type"]["definition"]["fields"]:
351
362
  # parentFields.append(field["name"])
352
363
  curOperation["type"]["definition"]["fields"] = checkForChildOperation(copy.deepcopy(curOperation["type"]["definition"]["fields"]),childOperations)
353
- curOperation["type"]["definition"]["fields"] = copy.deepcopy(getNestedFieldDefinitions(curOperation["type"]["definition"]["fields"], None,childOperations,[]))
364
+ curOperation["type"]["definition"]["fields"] = copy.deepcopy(getNestedFieldDefinitions(curOperation["type"]["definition"]["fields"], None,childOperations,[], curOperation["type"]["name"]))
354
365
  if "inputFields" in curOperation["type"]["definition"] and curOperation["type"]["definition"]["inputFields"] != None:
355
366
  parentFields = curOperation["type"]["definition"]["inputFields"].keys()
356
- curOperation["type"]["definition"]["inputFields"] = copy.deepcopy(getNestedFieldDefinitions(curOperation["type"]["definition"]["inputFields"], None,childOperations,parentFields))
367
+ curOperation["type"]["definition"]["inputFields"] = copy.deepcopy(getNestedFieldDefinitions(curOperation["type"]["definition"]["inputFields"], None,childOperations,parentFields, curOperation["type"]["name"]))
357
368
  return curOperation
358
369
 
359
370
  def checkForChildOperation(fieldsAry,childOperations):
@@ -1069,7 +1080,12 @@ def renderArgsAndFields(responseArgStr, variablesObj, curOperation, definition,
1069
1080
  responseArgStr += " {\n"
1070
1081
  for subfieldIndex in field['type']['definition']['fields']:
1071
1082
  subfield = field['type']['definition']['fields'][subfieldIndex]
1072
- subfield_name = subfield['alias'] if 'alias' in subfield else subfield['name']
1083
+ # updated logic: use fieldTypes to determine if aliasing is needed
1084
+ if (subfield['type']['name'] in curOperation.get('fieldTypes', {}) and
1085
+ 'SCALAR' not in subfield['type'].get('kind', [])):
1086
+ subfield_name = subfield['name'] + field['type']['definition']['name'] + ": " + subfield['name']
1087
+ else:
1088
+ subfield_name = subfield['alias'] if 'alias' in subfield else subfield['name']
1073
1089
  responseArgStr += indent + " " + subfield_name
1074
1090
  if subfield.get("args") and len(list(subfield["args"].keys()))>0:
1075
1091
  argsPresent = False
@@ -0,0 +1,89 @@
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())
@@ -0,0 +1,89 @@
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()