catocli 2.0.4__py3-none-any.whl → 2.0.5__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 (290) hide show
  1. build/lib/catocli/Utils/clidriver.py +268 -0
  2. build/lib/catocli/Utils/profile_manager.py +188 -0
  3. build/lib/catocli/Utils/version_checker.py +192 -0
  4. build/lib/catocli/__init__.py +2 -0
  5. build/lib/catocli/__main__.py +12 -0
  6. build/lib/catocli/parsers/configure/__init__.py +115 -0
  7. build/lib/catocli/parsers/configure/configure.py +307 -0
  8. build/lib/catocli/parsers/custom/__init__.py +57 -0
  9. build/lib/catocli/parsers/custom/customLib.py +561 -0
  10. build/lib/catocli/parsers/custom/export_rules/__init__.py +42 -0
  11. build/lib/catocli/parsers/custom/export_rules/export_rules.py +234 -0
  12. build/lib/catocli/parsers/custom/export_sites/__init__.py +21 -0
  13. build/lib/catocli/parsers/custom/export_sites/export_sites.py +372 -0
  14. build/lib/catocli/parsers/custom/import_rules_to_tf/__init__.py +58 -0
  15. build/lib/catocli/parsers/custom/import_rules_to_tf/import_rules_to_tf.py +451 -0
  16. build/lib/catocli/parsers/custom/import_sites_to_tf/__init__.py +45 -0
  17. build/lib/catocli/parsers/custom/import_sites_to_tf/import_sites_to_tf.py +891 -0
  18. build/lib/catocli/parsers/mutation_accountManagement/__init__.py +48 -0
  19. build/lib/catocli/parsers/mutation_admin/__init__.py +48 -0
  20. build/lib/catocli/parsers/mutation_container/__init__.py +138 -0
  21. build/lib/catocli/parsers/mutation_hardware/__init__.py +22 -0
  22. build/lib/catocli/parsers/mutation_policy/__init__.py +1305 -0
  23. build/lib/catocli/parsers/mutation_sandbox/__init__.py +35 -0
  24. build/lib/catocli/parsers/mutation_site/__init__.py +373 -0
  25. build/lib/catocli/parsers/mutation_sites/__init__.py +373 -0
  26. build/lib/catocli/parsers/mutation_xdr/__init__.py +48 -0
  27. build/lib/catocli/parsers/parserApiClient.py +513 -0
  28. build/lib/catocli/parsers/query_accountBySubdomain/__init__.py +16 -0
  29. build/lib/catocli/parsers/query_accountManagement/__init__.py +16 -0
  30. build/lib/catocli/parsers/query_accountMetrics/__init__.py +16 -0
  31. build/lib/catocli/parsers/query_accountRoles/__init__.py +16 -0
  32. build/lib/catocli/parsers/query_accountSnapshot/__init__.py +16 -0
  33. build/lib/catocli/parsers/query_admin/__init__.py +16 -0
  34. build/lib/catocli/parsers/query_admins/__init__.py +16 -0
  35. build/lib/catocli/parsers/query_appStats/__init__.py +16 -0
  36. build/lib/catocli/parsers/query_appStatsTimeSeries/__init__.py +16 -0
  37. build/lib/catocli/parsers/query_auditFeed/__init__.py +16 -0
  38. build/lib/catocli/parsers/query_catalogs/__init__.py +16 -0
  39. build/lib/catocli/parsers/query_container/__init__.py +16 -0
  40. build/lib/catocli/parsers/query_devices/__init__.py +16 -0
  41. build/lib/catocli/parsers/query_entityLookup/__init__.py +16 -0
  42. build/lib/catocli/parsers/query_events/__init__.py +16 -0
  43. build/lib/catocli/parsers/query_eventsFeed/__init__.py +16 -0
  44. build/lib/catocli/parsers/query_eventsTimeSeries/__init__.py +16 -0
  45. build/lib/catocli/parsers/query_hardware/__init__.py +16 -0
  46. build/lib/catocli/parsers/query_hardwareManagement/__init__.py +16 -0
  47. build/lib/catocli/parsers/query_licensing/__init__.py +16 -0
  48. build/lib/catocli/parsers/query_policy/__init__.py +161 -0
  49. build/lib/catocli/parsers/query_sandbox/__init__.py +16 -0
  50. build/lib/catocli/parsers/query_site/__init__.py +100 -0
  51. build/lib/catocli/parsers/query_siteLocation/__init__.py +13 -0
  52. build/lib/catocli/parsers/query_subDomains/__init__.py +16 -0
  53. build/lib/catocli/parsers/query_xdr/__init__.py +35 -0
  54. build/lib/catocli/parsers/raw/__init__.py +12 -0
  55. build/lib/graphql_client/__init__.py +11 -0
  56. build/lib/graphql_client/api/__init__.py +3 -0
  57. build/lib/graphql_client/api/call_api.py +84 -0
  58. build/lib/graphql_client/api_client.py +192 -0
  59. build/lib/graphql_client/api_client_types.py +409 -0
  60. build/lib/graphql_client/configuration.py +232 -0
  61. build/lib/graphql_client/models/__init__.py +13 -0
  62. build/lib/graphql_client/models/no_schema.py +71 -0
  63. build/lib/schema/catolib.py +1141 -0
  64. build/lib/schema/importSchema.py +60 -0
  65. build/lib/schema/remove_policyid.py +89 -0
  66. build/lib/schema/remove_policyid_mutations.py +89 -0
  67. build/lib/scripts/catolib.py +62 -0
  68. build/lib/scripts/export_if_rules_to_json.py +188 -0
  69. build/lib/scripts/export_wf_rules_to_json.py +111 -0
  70. build/lib/scripts/import_wf_rules_to_tfstate.py +331 -0
  71. build/lib/vendor/certifi/__init__.py +4 -0
  72. build/lib/vendor/certifi/__main__.py +12 -0
  73. build/lib/vendor/certifi/core.py +114 -0
  74. build/lib/vendor/certifi/py.typed +0 -0
  75. build/lib/vendor/six.py +998 -0
  76. build/lib/vendor/urllib3/__init__.py +211 -0
  77. build/lib/vendor/urllib3/_base_connection.py +172 -0
  78. build/lib/vendor/urllib3/_collections.py +483 -0
  79. build/lib/vendor/urllib3/_request_methods.py +278 -0
  80. build/lib/vendor/urllib3/_version.py +16 -0
  81. build/lib/vendor/urllib3/connection.py +1033 -0
  82. build/lib/vendor/urllib3/connectionpool.py +1182 -0
  83. build/lib/vendor/urllib3/contrib/__init__.py +0 -0
  84. build/lib/vendor/urllib3/contrib/emscripten/__init__.py +18 -0
  85. build/lib/vendor/urllib3/contrib/emscripten/connection.py +254 -0
  86. build/lib/vendor/urllib3/contrib/emscripten/fetch.py +418 -0
  87. build/lib/vendor/urllib3/contrib/emscripten/request.py +22 -0
  88. build/lib/vendor/urllib3/contrib/emscripten/response.py +285 -0
  89. build/lib/vendor/urllib3/contrib/pyopenssl.py +552 -0
  90. build/lib/vendor/urllib3/contrib/socks.py +228 -0
  91. build/lib/vendor/urllib3/exceptions.py +321 -0
  92. build/lib/vendor/urllib3/fields.py +341 -0
  93. build/lib/vendor/urllib3/filepost.py +89 -0
  94. build/lib/vendor/urllib3/http2/__init__.py +53 -0
  95. build/lib/vendor/urllib3/http2/connection.py +356 -0
  96. build/lib/vendor/urllib3/http2/probe.py +87 -0
  97. build/lib/vendor/urllib3/poolmanager.py +637 -0
  98. build/lib/vendor/urllib3/py.typed +2 -0
  99. build/lib/vendor/urllib3/response.py +1265 -0
  100. build/lib/vendor/urllib3/util/__init__.py +42 -0
  101. build/lib/vendor/urllib3/util/connection.py +137 -0
  102. build/lib/vendor/urllib3/util/proxy.py +43 -0
  103. build/lib/vendor/urllib3/util/request.py +256 -0
  104. build/lib/vendor/urllib3/util/response.py +101 -0
  105. build/lib/vendor/urllib3/util/retry.py +533 -0
  106. build/lib/vendor/urllib3/util/ssl_.py +513 -0
  107. build/lib/vendor/urllib3/util/ssl_match_hostname.py +159 -0
  108. build/lib/vendor/urllib3/util/ssltransport.py +276 -0
  109. build/lib/vendor/urllib3/util/timeout.py +275 -0
  110. build/lib/vendor/urllib3/util/url.py +471 -0
  111. build/lib/vendor/urllib3/util/util.py +42 -0
  112. build/lib/vendor/urllib3/util/wait.py +124 -0
  113. catocli/Utils/clidriver.py +1 -4
  114. catocli/__init__.py +1 -1
  115. catocli/parsers/custom/export_sites/export_sites.py +2 -2
  116. catocli/parsers/mutation_container/__init__.py +116 -0
  117. catocli/parsers/mutation_container_fqdn/README.md +7 -0
  118. catocli/parsers/mutation_container_fqdn_addValues/README.md +17 -0
  119. catocli/parsers/mutation_container_fqdn_createFromFile/README.md +17 -0
  120. catocli/parsers/mutation_container_fqdn_removeValues/README.md +17 -0
  121. catocli/parsers/mutation_container_fqdn_updateFromFile/README.md +17 -0
  122. catocli/parsers/mutation_container_ipAddressRange/README.md +7 -0
  123. catocli/parsers/mutation_container_ipAddressRange_addValues/README.md +17 -0
  124. catocli/parsers/mutation_container_ipAddressRange_createFromFile/README.md +17 -0
  125. catocli/parsers/mutation_container_ipAddressRange_removeValues/README.md +17 -0
  126. catocli/parsers/mutation_container_ipAddressRange_updateFromFile/README.md +17 -0
  127. catocli/parsers/mutation_policy_internetFirewall_addRule/README.md +1 -1
  128. catocli/parsers/mutation_policy_internetFirewall_updateRule/README.md +1 -1
  129. catocli/parsers/mutation_policy_wanFirewall_addRule/README.md +1 -1
  130. catocli/parsers/mutation_policy_wanFirewall_updateRule/README.md +1 -1
  131. catocli/parsers/parserApiClient.py +25 -11
  132. catocli/parsers/query_policy/README.md +0 -17
  133. catocli/parsers/query_policy/__init__.py +153 -8
  134. catocli/parsers/query_policy_appTenantRestriction/README.md +7 -0
  135. catocli/parsers/query_policy_appTenantRestriction_policy/README.md +17 -0
  136. catocli/parsers/query_policy_dynamicIpAllocation/README.md +7 -0
  137. catocli/parsers/query_policy_dynamicIpAllocation_policy/README.md +17 -0
  138. catocli/parsers/query_policy_internetFirewall/README.md +7 -0
  139. catocli/parsers/query_policy_internetFirewall_policy/README.md +17 -0
  140. catocli/parsers/query_policy_remotePortFwd/README.md +7 -0
  141. catocli/parsers/query_policy_remotePortFwd_policy/README.md +17 -0
  142. catocli/parsers/query_policy_socketLan/README.md +7 -0
  143. catocli/parsers/query_policy_socketLan_policy/README.md +17 -0
  144. catocli/parsers/query_policy_terminalServer/README.md +7 -0
  145. catocli/parsers/query_policy_terminalServer_policy/README.md +17 -0
  146. catocli/parsers/query_policy_wanFirewall/README.md +7 -0
  147. catocli/parsers/query_policy_wanFirewall_policy/README.md +17 -0
  148. catocli/parsers/query_policy_wanNetwork/README.md +7 -0
  149. catocli/parsers/query_policy_wanNetwork_policy/README.md +17 -0
  150. catocli/parsers/query_site/README.md +0 -16
  151. catocli/parsers/query_site/__init__.py +92 -8
  152. catocli/parsers/query_site_availableVersionList/README.md +17 -0
  153. catocli/parsers/query_site_bgpPeer/README.md +17 -0
  154. catocli/parsers/query_site_bgpPeerList/README.md +17 -0
  155. catocli/parsers/query_site_cloudInterconnectConnectionConnectivity/README.md +17 -0
  156. catocli/parsers/query_site_cloudInterconnectPhysicalConnection/README.md +17 -0
  157. catocli/parsers/query_site_cloudInterconnectPhysicalConnectionId/README.md +17 -0
  158. catocli/parsers/query_site_siteBgpStatus/README.md +17 -0
  159. catocli/parsers/raw/README.md +0 -14
  160. catocli/parsers/raw/__init__.py +0 -2
  161. {catocli-2.0.4.dist-info → catocli-2.0.5.dist-info}/METADATA +1 -1
  162. {catocli-2.0.4.dist-info → catocli-2.0.5.dist-info}/RECORD +290 -120
  163. {catocli-2.0.4.dist-info → catocli-2.0.5.dist-info}/top_level.txt +1 -0
  164. graphql_client/api/call_api.py +4 -3
  165. models/mutation.container.fqdn.addValues.json +866 -0
  166. models/mutation.container.fqdn.createFromFile.json +819 -0
  167. models/mutation.container.fqdn.removeValues.json +866 -0
  168. models/mutation.container.fqdn.updateFromFile.json +1045 -0
  169. models/mutation.container.ipAddressRange.addValues.json +1020 -0
  170. models/mutation.container.ipAddressRange.createFromFile.json +819 -0
  171. models/mutation.container.ipAddressRange.removeValues.json +1020 -0
  172. models/mutation.container.ipAddressRange.updateFromFile.json +1045 -0
  173. models/mutation.policy.appTenantRestriction.addRule.json +8 -8
  174. models/mutation.policy.appTenantRestriction.addSection.json +1 -1
  175. models/mutation.policy.appTenantRestriction.createPolicyRevision.json +2 -2
  176. models/mutation.policy.appTenantRestriction.discardPolicyRevision.json +2 -2
  177. models/mutation.policy.appTenantRestriction.moveRule.json +2 -2
  178. models/mutation.policy.appTenantRestriction.moveSection.json +1 -1
  179. models/mutation.policy.appTenantRestriction.publishPolicyRevision.json +2 -2
  180. models/mutation.policy.appTenantRestriction.removeRule.json +2 -2
  181. models/mutation.policy.appTenantRestriction.removeSection.json +1 -1
  182. models/mutation.policy.appTenantRestriction.updatePolicy.json +2 -2
  183. models/mutation.policy.appTenantRestriction.updateRule.json +8 -8
  184. models/mutation.policy.appTenantRestriction.updateSection.json +1 -1
  185. models/mutation.policy.dynamicIpAllocation.addRule.json +1 -1
  186. models/mutation.policy.dynamicIpAllocation.addSection.json +1 -1
  187. models/mutation.policy.dynamicIpAllocation.createPolicyRevision.json +1 -1
  188. models/mutation.policy.dynamicIpAllocation.discardPolicyRevision.json +1 -1
  189. models/mutation.policy.dynamicIpAllocation.moveRule.json +1 -1
  190. models/mutation.policy.dynamicIpAllocation.moveSection.json +1 -1
  191. models/mutation.policy.dynamicIpAllocation.publishPolicyRevision.json +1 -1
  192. models/mutation.policy.dynamicIpAllocation.removeRule.json +1 -1
  193. models/mutation.policy.dynamicIpAllocation.removeSection.json +1 -1
  194. models/mutation.policy.dynamicIpAllocation.updatePolicy.json +1 -1
  195. models/mutation.policy.dynamicIpAllocation.updateRule.json +1 -1
  196. models/mutation.policy.dynamicIpAllocation.updateSection.json +1 -1
  197. models/mutation.policy.internetFirewall.addRule.json +502 -55
  198. models/mutation.policy.internetFirewall.addSection.json +1 -1
  199. models/mutation.policy.internetFirewall.createPolicyRevision.json +127 -10
  200. models/mutation.policy.internetFirewall.discardPolicyRevision.json +127 -10
  201. models/mutation.policy.internetFirewall.moveRule.json +127 -10
  202. models/mutation.policy.internetFirewall.moveSection.json +1 -1
  203. models/mutation.policy.internetFirewall.publishPolicyRevision.json +127 -10
  204. models/mutation.policy.internetFirewall.removeRule.json +127 -10
  205. models/mutation.policy.internetFirewall.removeSection.json +1 -1
  206. models/mutation.policy.internetFirewall.updatePolicy.json +127 -10
  207. models/mutation.policy.internetFirewall.updateRule.json +493 -55
  208. models/mutation.policy.internetFirewall.updateSection.json +1 -1
  209. models/mutation.policy.remotePortFwd.addRule.json +5 -5
  210. models/mutation.policy.remotePortFwd.addSection.json +1 -1
  211. models/mutation.policy.remotePortFwd.createPolicyRevision.json +2 -2
  212. models/mutation.policy.remotePortFwd.discardPolicyRevision.json +2 -2
  213. models/mutation.policy.remotePortFwd.moveRule.json +2 -2
  214. models/mutation.policy.remotePortFwd.moveSection.json +1 -1
  215. models/mutation.policy.remotePortFwd.publishPolicyRevision.json +2 -2
  216. models/mutation.policy.remotePortFwd.removeRule.json +2 -2
  217. models/mutation.policy.remotePortFwd.removeSection.json +1 -1
  218. models/mutation.policy.remotePortFwd.updatePolicy.json +2 -2
  219. models/mutation.policy.remotePortFwd.updateRule.json +5 -5
  220. models/mutation.policy.remotePortFwd.updateSection.json +1 -1
  221. models/mutation.policy.socketLan.addRule.json +16 -16
  222. models/mutation.policy.socketLan.addSection.json +1 -1
  223. models/mutation.policy.socketLan.createPolicyRevision.json +4 -4
  224. models/mutation.policy.socketLan.discardPolicyRevision.json +4 -4
  225. models/mutation.policy.socketLan.moveRule.json +4 -4
  226. models/mutation.policy.socketLan.moveSection.json +1 -1
  227. models/mutation.policy.socketLan.publishPolicyRevision.json +4 -4
  228. models/mutation.policy.socketLan.removeRule.json +4 -4
  229. models/mutation.policy.socketLan.removeSection.json +1 -1
  230. models/mutation.policy.socketLan.updatePolicy.json +4 -4
  231. models/mutation.policy.socketLan.updateRule.json +16 -16
  232. models/mutation.policy.socketLan.updateSection.json +1 -1
  233. models/mutation.policy.terminalServer.addRule.json +1 -1
  234. models/mutation.policy.terminalServer.addSection.json +1 -1
  235. models/mutation.policy.terminalServer.createPolicyRevision.json +1 -1
  236. models/mutation.policy.terminalServer.discardPolicyRevision.json +1 -1
  237. models/mutation.policy.terminalServer.moveRule.json +1 -1
  238. models/mutation.policy.terminalServer.moveSection.json +1 -1
  239. models/mutation.policy.terminalServer.publishPolicyRevision.json +1 -1
  240. models/mutation.policy.terminalServer.removeRule.json +1 -1
  241. models/mutation.policy.terminalServer.removeSection.json +1 -1
  242. models/mutation.policy.terminalServer.updatePolicy.json +1 -1
  243. models/mutation.policy.terminalServer.updateRule.json +1 -1
  244. models/mutation.policy.terminalServer.updateSection.json +1 -1
  245. models/mutation.policy.wanFirewall.addRule.json +500 -53
  246. models/mutation.policy.wanFirewall.addSection.json +1 -1
  247. models/mutation.policy.wanFirewall.createPolicyRevision.json +128 -11
  248. models/mutation.policy.wanFirewall.discardPolicyRevision.json +128 -11
  249. models/mutation.policy.wanFirewall.moveRule.json +128 -11
  250. models/mutation.policy.wanFirewall.moveSection.json +1 -1
  251. models/mutation.policy.wanFirewall.publishPolicyRevision.json +128 -11
  252. models/mutation.policy.wanFirewall.removeRule.json +128 -11
  253. models/mutation.policy.wanFirewall.removeSection.json +1 -1
  254. models/mutation.policy.wanFirewall.updatePolicy.json +128 -11
  255. models/mutation.policy.wanFirewall.updateRule.json +491 -53
  256. models/mutation.policy.wanFirewall.updateSection.json +1 -1
  257. models/mutation.policy.wanNetwork.addRule.json +13 -13
  258. models/mutation.policy.wanNetwork.addSection.json +1 -1
  259. models/mutation.policy.wanNetwork.createPolicyRevision.json +1 -1
  260. models/mutation.policy.wanNetwork.discardPolicyRevision.json +1 -1
  261. models/mutation.policy.wanNetwork.moveRule.json +1 -1
  262. models/mutation.policy.wanNetwork.moveSection.json +1 -1
  263. models/mutation.policy.wanNetwork.publishPolicyRevision.json +1 -1
  264. models/mutation.policy.wanNetwork.removeRule.json +1 -1
  265. models/mutation.policy.wanNetwork.removeSection.json +1 -1
  266. models/mutation.policy.wanNetwork.updatePolicy.json +1 -1
  267. models/mutation.policy.wanNetwork.updateRule.json +13 -13
  268. models/mutation.policy.wanNetwork.updateSection.json +1 -1
  269. models/query.policy.appTenantRestriction.policy.json +3086 -0
  270. models/query.policy.dynamicIpAllocation.policy.json +1934 -0
  271. models/query.policy.internetFirewall.policy.json +7833 -0
  272. models/query.policy.json +233 -0
  273. models/query.policy.remotePortFwd.policy.json +2387 -0
  274. models/query.policy.socketLan.policy.json +7140 -0
  275. models/query.policy.terminalServer.policy.json +1632 -0
  276. models/query.policy.wanFirewall.policy.json +9212 -0
  277. models/query.policy.wanNetwork.policy.json +8010 -0
  278. models/query.site.availableVersionList.json +365 -0
  279. models/query.site.bgpPeer.json +1917 -0
  280. models/query.site.bgpPeerList.json +2076 -0
  281. models/query.site.cloudInterconnectConnectionConnectivity.json +298 -0
  282. models/query.site.cloudInterconnectPhysicalConnection.json +728 -0
  283. models/query.site.cloudInterconnectPhysicalConnectionId.json +660 -0
  284. models/query.site.siteBgpStatus.json +869 -0
  285. schema/catolib.py +13 -6
  286. schema/remove_policyid.py +89 -0
  287. schema/remove_policyid_mutations.py +89 -0
  288. {catocli-2.0.4.dist-info → catocli-2.0.5.dist-info}/LICENSE +0 -0
  289. {catocli-2.0.4.dist-info → catocli-2.0.5.dist-info}/WHEEL +0 -0
  290. {catocli-2.0.4.dist-info → catocli-2.0.5.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,268 @@
1
+
2
+ import os
3
+ import argparse
4
+ import json
5
+ import catocli
6
+ from graphql_client import Configuration
7
+ from graphql_client.api_client import ApiException
8
+ from ..parsers.parserApiClient import get_help
9
+ from .profile_manager import get_profile_manager
10
+ from .version_checker import check_for_updates, force_check_updates
11
+ import traceback
12
+ import sys
13
+ sys.path.insert(0, 'vendor')
14
+ import urllib3
15
+ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
16
+ # Initialize profile manager
17
+ profile_manager = get_profile_manager()
18
+ CATO_DEBUG = bool(os.getenv("CATO_DEBUG", False))
19
+ from ..parsers.raw import raw_parse
20
+ from ..parsers.custom import custom_parse
21
+ from ..parsers.query_siteLocation import query_siteLocation_parse
22
+ from ..parsers.mutation_accountManagement import mutation_accountManagement_parse
23
+ from ..parsers.mutation_admin import mutation_admin_parse
24
+ from ..parsers.mutation_container import mutation_container_parse
25
+ from ..parsers.mutation_hardware import mutation_hardware_parse
26
+ from ..parsers.mutation_policy import mutation_policy_parse
27
+ from ..parsers.mutation_sandbox import mutation_sandbox_parse
28
+ from ..parsers.mutation_site import mutation_site_parse
29
+ from ..parsers.mutation_sites import mutation_sites_parse
30
+ from ..parsers.mutation_xdr import mutation_xdr_parse
31
+ from ..parsers.query_accountBySubdomain import query_accountBySubdomain_parse
32
+ from ..parsers.query_accountManagement import query_accountManagement_parse
33
+ from ..parsers.query_accountMetrics import query_accountMetrics_parse
34
+ from ..parsers.query_accountRoles import query_accountRoles_parse
35
+ from ..parsers.query_accountSnapshot import query_accountSnapshot_parse
36
+ from ..parsers.query_admin import query_admin_parse
37
+ from ..parsers.query_admins import query_admins_parse
38
+ from ..parsers.query_appStats import query_appStats_parse
39
+ from ..parsers.query_appStatsTimeSeries import query_appStatsTimeSeries_parse
40
+ from ..parsers.query_auditFeed import query_auditFeed_parse
41
+ from ..parsers.query_catalogs import query_catalogs_parse
42
+ from ..parsers.query_container import query_container_parse
43
+ from ..parsers.query_devices import query_devices_parse
44
+ from ..parsers.query_entityLookup import query_entityLookup_parse
45
+ from ..parsers.query_events import query_events_parse
46
+ from ..parsers.query_eventsFeed import query_eventsFeed_parse
47
+ from ..parsers.query_eventsTimeSeries import query_eventsTimeSeries_parse
48
+ from ..parsers.query_hardware import query_hardware_parse
49
+ from ..parsers.query_hardwareManagement import query_hardwareManagement_parse
50
+ from ..parsers.query_licensing import query_licensing_parse
51
+ from ..parsers.query_policy import query_policy_parse
52
+ from ..parsers.query_sandbox import query_sandbox_parse
53
+ from ..parsers.query_site import query_site_parse
54
+ from ..parsers.query_subDomains import query_subDomains_parse
55
+ from ..parsers.query_xdr import query_xdr_parse
56
+
57
+ def show_version_info(args, configuration=None):
58
+ print(f"catocli version {catocli.__version__}")
59
+
60
+ if not args.current_only:
61
+ if args.check_updates:
62
+ # Force check for updates
63
+ is_newer, latest_version, source = force_check_updates()
64
+ else:
65
+ # Regular check (uses cache)
66
+ is_newer, latest_version, source = check_for_updates(show_if_available=False)
67
+
68
+ if latest_version:
69
+ if is_newer:
70
+ print(f"Latest version: {latest_version} (from {source}) - UPDATE AVAILABLE!")
71
+ print()
72
+ print("To upgrade, run:")
73
+ print("pip install --upgrade catocli")
74
+ else:
75
+ print(f"Latest version: {latest_version} (from {source}) - You are up to date!")
76
+ else:
77
+ print("Unable to check for updates (check your internet connection)")
78
+ return [{"success": True, "current_version": catocli.__version__, "latest_version": latest_version if not args.current_only else None}]
79
+
80
+ def get_configuration(skip_api_key=False):
81
+ configuration = Configuration()
82
+ configuration.verify_ssl = False
83
+ configuration.debug = CATO_DEBUG
84
+ configuration.version = "{}".format(catocli.__version__)
85
+
86
+ # Try to migrate from environment variables first
87
+ profile_manager.migrate_from_environment()
88
+
89
+ # Get credentials from profile
90
+ credentials = profile_manager.get_credentials()
91
+ if not credentials:
92
+ print("No Cato CLI profile configured.")
93
+ print("Run 'catocli configure set' to set up your credentials.")
94
+ exit(1)
95
+
96
+ if not credentials.get('cato_token') or not credentials.get('account_id'):
97
+ profile_name = profile_manager.get_current_profile()
98
+ print(f"Profile '{profile_name}' is missing required credentials.")
99
+ print(f"Run 'catocli configure set --profile {profile_name}' to update your credentials.")
100
+ exit(1)
101
+
102
+ # Only set API key if not using custom headers file
103
+ if not skip_api_key:
104
+ configuration.api_key["x-api-key"] = credentials['cato_token']
105
+ configuration.host = credentials['endpoint']
106
+ configuration.accountID = credentials['account_id']
107
+
108
+ return configuration
109
+
110
+ defaultReadmeStr = """
111
+ The Cato CLI is a command-line interface tool designed to simplify the management and automation of Cato Networks’ configurations and operations.
112
+ It enables users to interact with Cato’s API for tasks such as managing Cato Management Application (CMA) site and account configurations, security policies, retrieving events, etc.
113
+
114
+
115
+ For assistance in generating syntax for the cli to perform various operations, please refer to the Cato API Explorer application.
116
+
117
+
118
+ https://github.com/catonetworks/cato-api-explorer
119
+ """
120
+
121
+ parser = argparse.ArgumentParser(prog='catocli', usage='%(prog)s <operationType> <operationName> [options]', description=defaultReadmeStr)
122
+ parser.add_argument('--version', action='version', version=catocli.__version__)
123
+ parser.add_argument('-H', '--header', action='append', dest='headers', help='Add custom headers in "Key: Value" format. Can be used multiple times.')
124
+ parser.add_argument('--headers-file', dest='headers_file', help='Load headers from a file. Each line should contain a header in "Key: Value" format.')
125
+ subparsers = parser.add_subparsers()
126
+
127
+ # Version command - enhanced with update checking
128
+ version_parser = subparsers.add_parser('version', help='Show version information and check for updates')
129
+ version_parser.add_argument('--check-updates', action='store_true', help='Force check for updates (ignores cache)')
130
+ version_parser.add_argument('--current-only', action='store_true', help='Show only current version')
131
+ version_parser.set_defaults(func=show_version_info)
132
+
133
+ custom_parsers = custom_parse(subparsers)
134
+ raw_parsers = subparsers.add_parser('raw', help='Raw GraphQL', usage=get_help("raw"))
135
+ raw_parser = raw_parse(raw_parsers)
136
+ query_parser = subparsers.add_parser('query', help='Query', usage='catocli query <operationName> [options]')
137
+ query_subparsers = query_parser.add_subparsers(description='valid subcommands', help='additional help')
138
+ query_siteLocation_parser = query_siteLocation_parse(query_subparsers)
139
+ mutation_parser = subparsers.add_parser('mutation', help='Mutation', usage='catocli mutation <operationName> [options]')
140
+ mutation_subparsers = mutation_parser.add_subparsers(description='valid subcommands', help='additional help')
141
+
142
+ mutation_accountManagement_parser = mutation_accountManagement_parse(mutation_subparsers)
143
+ mutation_admin_parser = mutation_admin_parse(mutation_subparsers)
144
+ mutation_container_parser = mutation_container_parse(mutation_subparsers)
145
+ mutation_hardware_parser = mutation_hardware_parse(mutation_subparsers)
146
+ mutation_policy_parser = mutation_policy_parse(mutation_subparsers)
147
+ mutation_sandbox_parser = mutation_sandbox_parse(mutation_subparsers)
148
+ mutation_site_parser = mutation_site_parse(mutation_subparsers)
149
+ mutation_sites_parser = mutation_sites_parse(mutation_subparsers)
150
+ mutation_xdr_parser = mutation_xdr_parse(mutation_subparsers)
151
+ query_accountBySubdomain_parser = query_accountBySubdomain_parse(query_subparsers)
152
+ query_accountManagement_parser = query_accountManagement_parse(query_subparsers)
153
+ query_accountMetrics_parser = query_accountMetrics_parse(query_subparsers)
154
+ query_accountRoles_parser = query_accountRoles_parse(query_subparsers)
155
+ query_accountSnapshot_parser = query_accountSnapshot_parse(query_subparsers)
156
+ query_admin_parser = query_admin_parse(query_subparsers)
157
+ query_admins_parser = query_admins_parse(query_subparsers)
158
+ query_appStats_parser = query_appStats_parse(query_subparsers)
159
+ query_appStatsTimeSeries_parser = query_appStatsTimeSeries_parse(query_subparsers)
160
+ query_auditFeed_parser = query_auditFeed_parse(query_subparsers)
161
+ query_catalogs_parser = query_catalogs_parse(query_subparsers)
162
+ query_container_parser = query_container_parse(query_subparsers)
163
+ query_devices_parser = query_devices_parse(query_subparsers)
164
+ query_entityLookup_parser = query_entityLookup_parse(query_subparsers)
165
+ query_events_parser = query_events_parse(query_subparsers)
166
+ query_eventsFeed_parser = query_eventsFeed_parse(query_subparsers)
167
+ query_eventsTimeSeries_parser = query_eventsTimeSeries_parse(query_subparsers)
168
+ query_hardware_parser = query_hardware_parse(query_subparsers)
169
+ query_hardwareManagement_parser = query_hardwareManagement_parse(query_subparsers)
170
+ query_licensing_parser = query_licensing_parse(query_subparsers)
171
+ query_policy_parser = query_policy_parse(query_subparsers)
172
+ query_sandbox_parser = query_sandbox_parse(query_subparsers)
173
+ query_site_parser = query_site_parse(query_subparsers)
174
+ query_subDomains_parser = query_subDomains_parse(query_subparsers)
175
+ query_xdr_parser = query_xdr_parse(query_subparsers)
176
+
177
+
178
+ def parse_headers(header_strings):
179
+ headers = {}
180
+ if header_strings:
181
+ for header_string in header_strings:
182
+ if ':' not in header_string:
183
+ print(f"ERROR: Invalid header format '{header_string}'. Use 'Key: Value' format.")
184
+ exit(1)
185
+ key, value = header_string.split(':', 1)
186
+ headers[key.strip()] = value.strip()
187
+ return headers
188
+
189
+ def parse_headers_from_file(file_path):
190
+ headers = {}
191
+ try:
192
+ with open(file_path, 'r') as f:
193
+ for line_num, line in enumerate(f, 1):
194
+ line = line.strip()
195
+ if not line or line.startswith('#'):
196
+ # Skip empty lines and comments
197
+ continue
198
+ if ':' not in line:
199
+ print(f"ERROR: Invalid header format in {file_path} at line {line_num}: '{line}'. Use 'Key: Value' format.")
200
+ exit(1)
201
+ key, value = line.split(':', 1)
202
+ headers[key.strip()] = value.strip()
203
+ except FileNotFoundError:
204
+ print(f"ERROR: Headers file '{file_path}' not found.")
205
+ exit(1)
206
+ except IOError as e:
207
+ print(f"ERROR: Could not read headers file '{file_path}': {e}")
208
+ exit(1)
209
+ return headers
210
+
211
+ def main(args=None):
212
+ # Check if no arguments provided or help is requested
213
+ if args is None:
214
+ args = sys.argv[1:]
215
+
216
+ # Show version check when displaying help or when no command specified
217
+ if not args or '-h' in args or '--help' in args:
218
+ # Check for updates in background (non-blocking)
219
+ try:
220
+ check_for_updates(show_if_available=True)
221
+ except Exception:
222
+ # Don't let version check interfere with CLI operation
223
+ pass
224
+
225
+ args = parser.parse_args(args=args)
226
+ try:
227
+ # Skip authentication for configure commands
228
+ if hasattr(args, 'func') and hasattr(args.func, '__module__') and 'configure' in str(args.func.__module__):
229
+ response = args.func(args, None)
230
+ else:
231
+ # Check if using headers file to determine if we should skip API key
232
+ using_headers_file = hasattr(args, 'headers_file') and args.headers_file
233
+
234
+ # Get configuration from profiles
235
+ configuration = get_configuration(skip_api_key=using_headers_file)
236
+
237
+ # Parse custom headers if provided
238
+ custom_headers = {}
239
+ if hasattr(args, 'headers') and args.headers:
240
+ custom_headers.update(parse_headers(args.headers))
241
+ if hasattr(args, 'headers_file') and args.headers_file:
242
+ custom_headers.update(parse_headers_from_file(args.headers_file))
243
+ if custom_headers:
244
+ configuration.custom_headers.update(custom_headers)
245
+ # Handle account ID override
246
+ if args.func.__name__ != "createRawRequest":
247
+ if hasattr(args, 'accountID') and args.accountID is not None:
248
+ # Command line override takes precedence
249
+ configuration.accountID = args.accountID
250
+ # Otherwise use the account ID from the profile (already set in get_configuration)
251
+ response = args.func(args, configuration)
252
+
253
+ if type(response) == ApiException:
254
+ print("ERROR! Status code: {}".format(response.status))
255
+ print(response)
256
+ else:
257
+ if response!=None:
258
+ print(json.dumps(response[0], sort_keys=True, indent=4))
259
+ except Exception as e:
260
+ if isinstance(e, AttributeError):
261
+ print('Missing arguments. Usage: catocli <operation> -h')
262
+ if args.v==True:
263
+ print('ERROR: ',e)
264
+ traceback.print_exc()
265
+ else:
266
+ print('ERROR: ',e)
267
+ traceback.print_exc()
268
+ exit(1)
@@ -0,0 +1,188 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Profile management for Cato CLI authentication
4
+ Supports AWS CLI-style profiles with credentials stored in ~/.cato/credentials
5
+ """
6
+
7
+ import os
8
+ import configparser
9
+ from pathlib import Path
10
+ import sys
11
+
12
+
13
+ class ProfileManager:
14
+ """Manages Cato CLI profiles and credentials"""
15
+
16
+ def __init__(self):
17
+ self.cato_dir = Path.home() / '.cato'
18
+ self.credentials_file = self.cato_dir / 'credentials'
19
+ self.config_file = self.cato_dir / 'config'
20
+ self.default_endpoint = "https://api.catonetworks.com/api/v1/graphql2"
21
+
22
+ def ensure_cato_directory(self):
23
+ """Ensure ~/.cato directory exists"""
24
+ self.cato_dir.mkdir(mode=0o700, exist_ok=True)
25
+
26
+ def get_profile_config(self, profile_name='default'):
27
+ """Get configuration for a specific profile"""
28
+ if not self.credentials_file.exists():
29
+ return None
30
+
31
+ config = configparser.ConfigParser()
32
+ config.read(self.credentials_file)
33
+
34
+ if profile_name not in config:
35
+ return None
36
+
37
+ profile_config = dict(config[profile_name])
38
+
39
+ # Ensure required fields have defaults
40
+ if 'endpoint' not in profile_config:
41
+ profile_config['endpoint'] = self.default_endpoint
42
+
43
+ return profile_config
44
+
45
+ def list_profiles(self):
46
+ """List all available profiles"""
47
+ if not self.credentials_file.exists():
48
+ return []
49
+
50
+ config = configparser.ConfigParser()
51
+ config.read(self.credentials_file)
52
+ return list(config.sections())
53
+
54
+ def create_profile(self, profile_name, endpoint=None, cato_token=None, account_id=None):
55
+ """Create or update a profile"""
56
+ self.ensure_cato_directory()
57
+
58
+ config = configparser.ConfigParser()
59
+ if self.credentials_file.exists():
60
+ config.read(self.credentials_file)
61
+
62
+ if profile_name not in config:
63
+ config.add_section(profile_name)
64
+
65
+ if endpoint:
66
+ config[profile_name]['endpoint'] = endpoint
67
+ elif 'endpoint' not in config[profile_name]:
68
+ config[profile_name]['endpoint'] = self.default_endpoint
69
+
70
+ if cato_token:
71
+ config[profile_name]['cato_token'] = cato_token
72
+
73
+ if account_id:
74
+ config[profile_name]['account_id'] = account_id
75
+
76
+ with open(self.credentials_file, 'w') as f:
77
+ config.write(f)
78
+
79
+ # Set secure permissions
80
+ os.chmod(self.credentials_file, 0o600)
81
+
82
+ return True
83
+
84
+ def delete_profile(self, profile_name):
85
+ """Delete a profile"""
86
+ if not self.credentials_file.exists():
87
+ return False
88
+
89
+ config = configparser.ConfigParser()
90
+ config.read(self.credentials_file)
91
+
92
+ if profile_name not in config:
93
+ return False
94
+
95
+ config.remove_section(profile_name)
96
+
97
+ with open(self.credentials_file, 'w') as f:
98
+ config.write(f)
99
+
100
+ return True
101
+
102
+ def get_current_profile(self):
103
+ """Get the current active profile name"""
104
+ # Check environment variable first
105
+ profile = os.getenv('CATO_PROFILE')
106
+ if profile:
107
+ return profile
108
+
109
+ # Check config file
110
+ if self.config_file.exists():
111
+ config = configparser.ConfigParser()
112
+ config.read(self.config_file)
113
+ if 'default' in config and 'profile' in config['default']:
114
+ return config['default']['profile']
115
+
116
+ return 'default'
117
+
118
+ def set_current_profile(self, profile_name):
119
+ """Set the current active profile"""
120
+ self.ensure_cato_directory()
121
+
122
+ config = configparser.ConfigParser()
123
+ if self.config_file.exists():
124
+ config.read(self.config_file)
125
+
126
+ if 'default' not in config:
127
+ config.add_section('default')
128
+
129
+ config['default']['profile'] = profile_name
130
+
131
+ with open(self.config_file, 'w') as f:
132
+ config.write(f)
133
+
134
+ return True
135
+
136
+ def get_credentials(self, profile_name=None):
137
+ """Get credentials for the specified or current profile"""
138
+ if profile_name is None:
139
+ profile_name = self.get_current_profile()
140
+
141
+ profile_config = self.get_profile_config(profile_name)
142
+ if not profile_config:
143
+ return None
144
+
145
+ return {
146
+ 'endpoint': profile_config.get('endpoint', self.default_endpoint),
147
+ 'cato_token': profile_config.get('cato_token'),
148
+ 'account_id': profile_config.get('account_id')
149
+ }
150
+
151
+ def validate_profile(self, profile_name=None):
152
+ """Validate that a profile has all required credentials"""
153
+ credentials = self.get_credentials(profile_name)
154
+ if not credentials:
155
+ return False, f"Profile '{profile_name or self.get_current_profile()}' not found"
156
+
157
+ missing = []
158
+ if not credentials.get('cato_token'):
159
+ missing.append('cato_token')
160
+ if not credentials.get('account_id'):
161
+ missing.append('account_id')
162
+
163
+ if missing:
164
+ return False, f"Profile missing required fields: {', '.join(missing)}"
165
+
166
+ return True, "Profile is valid"
167
+
168
+ def migrate_from_environment(self):
169
+ """Migrate from environment variables to default profile if needed"""
170
+ cato_token = os.getenv('CATO_TOKEN')
171
+ account_id = os.getenv('CATO_ACCOUNT_ID')
172
+
173
+ if cato_token and account_id:
174
+ # Check if default profile already exists
175
+ default_config = self.get_profile_config('default')
176
+ if not default_config:
177
+ print("Migrating environment variables to default profile...")
178
+ self.create_profile('default',
179
+ endpoint=self.default_endpoint,
180
+ cato_token=cato_token,
181
+ account_id=account_id)
182
+ return True
183
+ return False
184
+
185
+
186
+ def get_profile_manager():
187
+ """Get a ProfileManager instance"""
188
+ return ProfileManager()
@@ -0,0 +1,192 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Version checking utility for Cato CLI
4
+ Checks for newer versions available on GitHub releases and PyPI
5
+ """
6
+
7
+ import json
8
+ import urllib.request
9
+ import urllib.error
10
+ import ssl
11
+ import os
12
+ import time
13
+ from .. import __version__
14
+
15
+ # Cache settings
16
+ CACHE_FILE = os.path.expanduser("~/.catocli_version_cache")
17
+ CACHE_DURATION = 3600 * 24 # 24 hours in seconds
18
+
19
+ def get_cached_version_info():
20
+ """Get cached version information if still valid"""
21
+ try:
22
+ if os.path.exists(CACHE_FILE):
23
+ with open(CACHE_FILE, 'r') as f:
24
+ cache_data = json.load(f)
25
+
26
+ # Check if cache is still valid
27
+ if time.time() - cache_data.get('timestamp', 0) < CACHE_DURATION:
28
+ return cache_data.get('latest_version'), cache_data.get('source')
29
+ except (json.JSONDecodeError, OSError):
30
+ pass
31
+ return None, None
32
+
33
+ def cache_version_info(latest_version, source):
34
+ """Cache version information"""
35
+ try:
36
+ cache_data = {
37
+ 'latest_version': latest_version,
38
+ 'source': source,
39
+ 'timestamp': time.time()
40
+ }
41
+ with open(CACHE_FILE, 'w') as f:
42
+ json.dump(cache_data, f)
43
+ except OSError:
44
+ pass # Fail silently if we can't write cache
45
+
46
+ def get_latest_github_version():
47
+ """Get the latest version from GitHub releases"""
48
+ try:
49
+ # Create SSL context that doesn't verify certificates (for corporate networks)
50
+ context = ssl.create_default_context()
51
+ context.check_hostname = False
52
+ context.verify_mode = ssl.CERT_NONE
53
+
54
+ url = "https://api.github.com/repos/catonetworks/cato-cli/releases/latest"
55
+ req = urllib.request.Request(url)
56
+ req.add_header('User-Agent', f'catocli/{__version__}')
57
+
58
+ with urllib.request.urlopen(req, context=context, timeout=5) as response:
59
+ data = json.loads(response.read().decode())
60
+ tag_name = data.get('tag_name', '')
61
+ # Remove 'v' prefix if present
62
+ if tag_name.startswith('v'):
63
+ tag_name = tag_name[1:]
64
+ return tag_name
65
+ except (urllib.error.URLError, urllib.error.HTTPError, json.JSONDecodeError, KeyError):
66
+ return None
67
+
68
+ def get_latest_pypi_version():
69
+ """Get the latest version from PyPI"""
70
+ try:
71
+ # Create SSL context that doesn't verify certificates (for corporate networks)
72
+ context = ssl.create_default_context()
73
+ context.check_hostname = False
74
+ context.verify_mode = ssl.CERT_NONE
75
+
76
+ url = "https://pypi.org/pypi/catocli/json"
77
+ req = urllib.request.Request(url)
78
+ req.add_header('User-Agent', f'catocli/{__version__}')
79
+
80
+ with urllib.request.urlopen(req, context=context, timeout=5) as response:
81
+ data = json.loads(response.read().decode())
82
+ return data['info']['version']
83
+ except (urllib.error.URLError, urllib.error.HTTPError, json.JSONDecodeError, KeyError):
84
+ return None
85
+
86
+ def get_latest_version():
87
+ """Get the latest version available from GitHub or PyPI"""
88
+ # Check cache first
89
+ cached_version, cached_source = get_cached_version_info()
90
+ if cached_version:
91
+ return cached_version, cached_source
92
+
93
+ # Try GitHub first (usually more up-to-date for development releases)
94
+ github_version = get_latest_github_version()
95
+ if github_version:
96
+ cache_version_info(github_version, 'GitHub')
97
+ return github_version, 'GitHub'
98
+
99
+ # Fall back to PyPI
100
+ pypi_version = get_latest_pypi_version()
101
+ if pypi_version:
102
+ cache_version_info(pypi_version, 'PyPI')
103
+ return pypi_version, 'PyPI'
104
+
105
+ return None, None
106
+
107
+ def compare_versions(version1, version2):
108
+ """Compare two version strings. Returns 1 if version1 > version2, -1 if version1 < version2, 0 if equal"""
109
+ def version_tuple(v):
110
+ # Convert version string to tuple of integers for comparison
111
+ # Handle versions like "1.0.20", "1.0.20-beta", etc.
112
+ parts = v.split('-')[0].split('.') # Remove pre-release suffixes
113
+ return tuple(int(x) for x in parts if x.isdigit())
114
+
115
+ try:
116
+ v1_tuple = version_tuple(version1)
117
+ v2_tuple = version_tuple(version2)
118
+
119
+ # Pad shorter version with zeros
120
+ max_len = max(len(v1_tuple), len(v2_tuple))
121
+ v1_tuple += (0,) * (max_len - len(v1_tuple))
122
+ v2_tuple += (0,) * (max_len - len(v2_tuple))
123
+
124
+ if v1_tuple > v2_tuple:
125
+ return 1
126
+ elif v1_tuple < v2_tuple:
127
+ return -1
128
+ else:
129
+ return 0
130
+ except (ValueError, AttributeError):
131
+ return 0 # If we can't parse, assume they're equal
132
+
133
+ def is_newer_version_available():
134
+ """Check if a newer version is available"""
135
+ try:
136
+ latest_version, source = get_latest_version()
137
+ if latest_version:
138
+ comparison = compare_versions(latest_version, __version__)
139
+ return comparison > 0, latest_version, source
140
+ except Exception:
141
+ pass # Fail silently for any version parsing errors
142
+
143
+ return False, None, None
144
+
145
+ def show_upgrade_message(latest_version, source):
146
+ """Display upgrade message to user"""
147
+ print()
148
+ print("─" * 60)
149
+ print(f"🚀 A newer version of catocli is available!")
150
+ print(f" Current version: {__version__}")
151
+ print(f" Latest version: {latest_version} (from {source})")
152
+ print()
153
+ if source == 'PyPI':
154
+ print(" To upgrade, run:")
155
+ print(" pip install --upgrade catocli")
156
+ else:
157
+ print(" To upgrade, run:")
158
+ print(" pip install --upgrade catocli")
159
+ print(" (or check GitHub releases for pre-release versions)")
160
+ print("─" * 60)
161
+ print()
162
+
163
+ def check_for_updates(show_if_available=True):
164
+ """
165
+ Check for updates and optionally show upgrade message
166
+
167
+ Args:
168
+ show_if_available (bool): Whether to show the upgrade message if update is available
169
+
170
+ Returns:
171
+ tuple: (is_newer_available, latest_version, source)
172
+ """
173
+ try:
174
+ is_newer, latest_version, source = is_newer_version_available()
175
+
176
+ if is_newer and show_if_available:
177
+ show_upgrade_message(latest_version, source)
178
+
179
+ return is_newer, latest_version, source
180
+ except Exception:
181
+ # Fail silently - don't interrupt the user's workflow
182
+ return False, None, None
183
+
184
+ def force_check_updates():
185
+ """Force check for updates by clearing cache"""
186
+ try:
187
+ if os.path.exists(CACHE_FILE):
188
+ os.remove(CACHE_FILE)
189
+ except OSError:
190
+ pass
191
+
192
+ return check_for_updates(show_if_available=True)
@@ -0,0 +1,2 @@
1
+ __version__ = "2.0.5"
2
+ __cato_host__ = "https://api.catonetworks.com/api/v1/graphql2"
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env python
2
+ import sys
3
+ from .Utils import clidriver
4
+
5
+ def main():
6
+ if sys.argv.__len__() == 1:
7
+ print('Usage: catocli -h')
8
+ else:
9
+ sys.exit(clidriver.main(sys.argv[1:]))
10
+
11
+ if __name__ == '__main__':
12
+ main()