catocli 2.0.1__py3-none-any.whl → 2.0.2__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 (104) hide show
  1. catocli/Utils/clidriver.py +37 -5
  2. catocli/__init__.py +1 -1
  3. catocli/parsers/custom/__init__.py +3 -2
  4. catocli/parsers/custom/customLib.py +252 -1
  5. catocli/parsers/custom/export_rules/__init__.py +5 -1
  6. catocli/parsers/custom/export_rules/export_rules.py +31 -182
  7. catocli/parsers/custom/export_sites/__init__.py +20 -0
  8. catocli/parsers/custom/export_sites/export_sites.py +233 -0
  9. catocli/parsers/custom/import_rules_to_tf/__init__.py +2 -2
  10. catocli/parsers/custom/import_rules_to_tf/import_rules_to_tf.py +19 -9
  11. catocli/parsers/mutation_accountManagement/__init__.py +15 -18
  12. catocli/parsers/mutation_admin/__init__.py +15 -18
  13. catocli/parsers/mutation_container/__init__.py +5 -6
  14. catocli/parsers/mutation_hardware/__init__.py +5 -6
  15. catocli/parsers/mutation_policy/__init__.py +582 -504
  16. catocli/parsers/mutation_policy_terminalServer/README.md +7 -0
  17. catocli/parsers/mutation_policy_terminalServer_addRule/README.md +18 -0
  18. catocli/parsers/mutation_policy_terminalServer_addSection/README.md +18 -0
  19. catocli/parsers/mutation_policy_terminalServer_createPolicyRevision/README.md +18 -0
  20. catocli/parsers/mutation_policy_terminalServer_discardPolicyRevision/README.md +18 -0
  21. catocli/parsers/mutation_policy_terminalServer_moveRule/README.md +18 -0
  22. catocli/parsers/mutation_policy_terminalServer_moveSection/README.md +18 -0
  23. catocli/parsers/mutation_policy_terminalServer_publishPolicyRevision/README.md +18 -0
  24. catocli/parsers/mutation_policy_terminalServer_removeRule/README.md +18 -0
  25. catocli/parsers/mutation_policy_terminalServer_removeSection/README.md +18 -0
  26. catocli/parsers/mutation_policy_terminalServer_updatePolicy/README.md +18 -0
  27. catocli/parsers/mutation_policy_terminalServer_updateRule/README.md +18 -0
  28. catocli/parsers/mutation_policy_terminalServer_updateSection/README.md +18 -0
  29. catocli/parsers/mutation_sandbox/__init__.py +10 -12
  30. catocli/parsers/mutation_site/__init__.py +164 -150
  31. catocli/parsers/mutation_site_addSocketAddOnCard/README.md +17 -0
  32. catocli/parsers/mutation_site_removeSocketAddOnCard/README.md +17 -0
  33. catocli/parsers/mutation_site_startSiteUpgrade/README.md +17 -0
  34. catocli/parsers/mutation_sites/__init__.py +164 -150
  35. catocli/parsers/mutation_sites_addSocketAddOnCard/README.md +17 -0
  36. catocli/parsers/mutation_sites_removeSocketAddOnCard/README.md +17 -0
  37. catocli/parsers/mutation_sites_startSiteUpgrade/README.md +17 -0
  38. catocli/parsers/mutation_xdr/__init__.py +15 -18
  39. catocli/parsers/query_accountBySubdomain/__init__.py +5 -6
  40. catocli/parsers/query_accountManagement/__init__.py +5 -6
  41. catocli/parsers/query_accountMetrics/__init__.py +5 -6
  42. catocli/parsers/query_accountRoles/__init__.py +5 -6
  43. catocli/parsers/query_accountSnapshot/__init__.py +5 -6
  44. catocli/parsers/query_admin/__init__.py +5 -6
  45. catocli/parsers/query_admins/__init__.py +5 -6
  46. catocli/parsers/query_appStats/__init__.py +5 -6
  47. catocli/parsers/query_appStatsTimeSeries/__init__.py +5 -6
  48. catocli/parsers/query_auditFeed/__init__.py +5 -6
  49. catocli/parsers/query_catalogs/__init__.py +5 -6
  50. catocli/parsers/query_container/__init__.py +5 -6
  51. catocli/parsers/query_devices/README.md +2 -1
  52. catocli/parsers/query_devices/__init__.py +5 -6
  53. catocli/parsers/query_entityLookup/__init__.py +5 -6
  54. catocli/parsers/query_events/__init__.py +5 -6
  55. catocli/parsers/query_eventsFeed/README.md +1 -1
  56. catocli/parsers/query_eventsFeed/__init__.py +5 -6
  57. catocli/parsers/query_eventsTimeSeries/__init__.py +5 -6
  58. catocli/parsers/query_hardware/__init__.py +5 -6
  59. catocli/parsers/query_hardwareManagement/__init__.py +5 -6
  60. catocli/parsers/query_licensing/__init__.py +5 -6
  61. catocli/parsers/query_policy/README.md +2 -1
  62. catocli/parsers/query_policy/__init__.py +5 -6
  63. catocli/parsers/query_sandbox/__init__.py +5 -6
  64. catocli/parsers/query_site/README.md +2 -1
  65. catocli/parsers/query_site/__init__.py +5 -6
  66. catocli/parsers/query_siteLocation/__init__.py +3 -7
  67. catocli/parsers/query_subDomains/__init__.py +5 -6
  68. catocli/parsers/query_xdr/__init__.py +10 -12
  69. catocli/parsers/raw/__init__.py +2 -0
  70. {catocli-2.0.1.dist-info → catocli-2.0.2.dist-info}/METADATA +1 -1
  71. {catocli-2.0.1.dist-info → catocli-2.0.2.dist-info}/RECORD +104 -65
  72. graphql_client/api/call_api.py +12 -6
  73. models/mutation.policy.remotePortFwd.updateRule.json +6 -6
  74. models/mutation.policy.terminalServer.addRule.json +2403 -0
  75. models/mutation.policy.terminalServer.addSection.json +1358 -0
  76. models/mutation.policy.terminalServer.createPolicyRevision.json +1873 -0
  77. models/mutation.policy.terminalServer.discardPolicyRevision.json +1807 -0
  78. models/mutation.policy.terminalServer.moveRule.json +1605 -0
  79. models/mutation.policy.terminalServer.moveSection.json +1259 -0
  80. models/mutation.policy.terminalServer.publishPolicyRevision.json +1864 -0
  81. models/mutation.policy.terminalServer.removeRule.json +1253 -0
  82. models/mutation.policy.terminalServer.removeSection.json +958 -0
  83. models/mutation.policy.terminalServer.updatePolicy.json +1883 -0
  84. models/mutation.policy.terminalServer.updateRule.json +2096 -0
  85. models/mutation.policy.terminalServer.updateSection.json +1111 -0
  86. models/mutation.site.addSocketAddOnCard.json +1050 -0
  87. models/mutation.site.removeSocketAddOnCard.json +786 -0
  88. models/mutation.site.startSiteUpgrade.json +802 -0
  89. models/mutation.sites.addSocketAddOnCard.json +1050 -0
  90. models/mutation.sites.removeSocketAddOnCard.json +786 -0
  91. models/mutation.sites.startSiteUpgrade.json +802 -0
  92. models/query.devices.json +311 -2
  93. models/query.events.json +48 -0
  94. models/query.eventsFeed.json +12 -0
  95. models/query.eventsTimeSeries.json +36 -0
  96. models/query.licensing.json +21815 -10093
  97. models/query.policy.json +1898 -305
  98. models/query.site.json +225 -0
  99. models/query.siteLocation.json +97190 -295396
  100. schema/catolib.py +52 -24
  101. {catocli-2.0.1.dist-info → catocli-2.0.2.dist-info}/LICENSE +0 -0
  102. {catocli-2.0.1.dist-info → catocli-2.0.2.dist-info}/WHEEL +0 -0
  103. {catocli-2.0.1.dist-info → catocli-2.0.2.dist-info}/entry_points.txt +0 -0
  104. {catocli-2.0.1.dist-info → catocli-2.0.2.dist-info}/top_level.txt +0 -0
schema/catolib.py CHANGED
@@ -552,7 +552,7 @@ def show_version_info(args, configuration=None):
552
552
  print("Unable to check for updates (check your internet connection)")
553
553
  return [{"success": True, "current_version": catocli.__version__, "latest_version": latest_version if not args.current_only else None}]
554
554
 
555
- def get_configuration():
555
+ def get_configuration(skip_api_key=False):
556
556
  configuration = Configuration()
557
557
  configuration.verify_ssl = False
558
558
  configuration.debug = CATO_DEBUG
@@ -574,7 +574,9 @@ def get_configuration():
574
574
  print(f"Run 'catocli configure set --profile {profile_name}' to update your credentials.")
575
575
  exit(1)
576
576
 
577
- configuration.api_key["x-api-key"] = credentials['cato_token']
577
+ # Only set API key if not using custom headers file
578
+ if not skip_api_key:
579
+ configuration.api_key["x-api-key"] = credentials['cato_token']
578
580
  configuration.host = credentials['endpoint']
579
581
  configuration.accountID = credentials['account_id']
580
582
 
@@ -590,6 +592,7 @@ https://github.com/catonetworks/cato-api-explorer
590
592
  parser = argparse.ArgumentParser(prog='catocli', usage='%(prog)s <operationType> <operationName> [options]', description=defaultReadmeStr)
591
593
  parser.add_argument('--version', action='version', version=catocli.__version__)
592
594
  parser.add_argument('-H', '--header', action='append', dest='headers', help='Add custom headers in "Key: Value" format. Can be used multiple times.')
595
+ parser.add_argument('--headers-file', dest='headers_file', help='Load headers from a file. Each line should contain a header in "Key: Value" format.')
593
596
  subparsers = parser.add_subparsers()
594
597
 
595
598
  # Version command - enhanced with update checking
@@ -624,6 +627,28 @@ def parse_headers(header_strings):
624
627
  headers[key.strip()] = value.strip()
625
628
  return headers
626
629
 
630
+ def parse_headers_from_file(file_path):
631
+ headers = {}
632
+ try:
633
+ with open(file_path, 'r') as f:
634
+ for line_num, line in enumerate(f, 1):
635
+ line = line.strip()
636
+ if not line or line.startswith('#'):
637
+ # Skip empty lines and comments
638
+ continue
639
+ if ':' not in line:
640
+ print(f"ERROR: Invalid header format in {file_path} at line {line_num}: '{line}'. Use 'Key: Value' format.")
641
+ exit(1)
642
+ key, value = line.split(':', 1)
643
+ headers[key.strip()] = value.strip()
644
+ except FileNotFoundError:
645
+ print(f"ERROR: Headers file '{file_path}' not found.")
646
+ exit(1)
647
+ except IOError as e:
648
+ print(f"ERROR: Could not read headers file '{file_path}': {e}")
649
+ exit(1)
650
+ return headers
651
+
627
652
  def main(args=None):
628
653
  # Check if no arguments provided or help is requested
629
654
  if args is None:
@@ -644,13 +669,20 @@ def main(args=None):
644
669
  if hasattr(args, 'func') and hasattr(args.func, '__module__') and 'configure' in str(args.func.__module__):
645
670
  response = args.func(args, None)
646
671
  else:
672
+ # Check if using headers file to determine if we should skip API key
673
+ using_headers_file = hasattr(args, 'headers_file') and args.headers_file
674
+
647
675
  # Get configuration from profiles
648
- configuration = get_configuration()
676
+ configuration = get_configuration(skip_api_key=using_headers_file)
649
677
 
650
678
  # Parse custom headers if provided
679
+ custom_headers = {}
651
680
  if hasattr(args, 'headers') and args.headers:
652
- custom_headers = parse_headers(args.headers)
653
- configuration.custom_headers.update(custom_headers)
681
+ custom_headers.update(parse_headers(args.headers))
682
+ if hasattr(args, 'headers_file') and args.headers_file:
683
+ custom_headers.update(parse_headers_from_file(args.headers_file))
684
+ if custom_headers:
685
+ configuration.custom_headers.update(custom_headers)
654
686
  # Handle account ID override
655
687
  if args.func.__name__ != "createRawRequest":
656
688
  if hasattr(args, 'accountID') and args.accountID is not None:
@@ -689,6 +721,8 @@ def raw_parse(raw_parser):
689
721
  raw_parser.add_argument('-t', const=True, default=False, nargs='?', help='Print test request preview without sending api call')
690
722
  raw_parser.add_argument('-v', const=True, default=False, nargs='?', help='Verbose output')
691
723
  raw_parser.add_argument('-p', const=True, default=False, nargs='?', help='Pretty print')
724
+ raw_parser.add_argument('-H', '--header', action='append', dest='headers', help='Add custom headers in "Key: Value" format. Can be used multiple times.')
725
+ raw_parser.add_argument('--headers-file', dest='headers_file', help='Load headers from a file. Each line should contain a header in "Key: Value" format.')
692
726
  raw_parser.set_defaults(func=createRawRequest,operation_name='raw')
693
727
  """
694
728
  parserPath = "../catocli/parsers/raw"
@@ -704,15 +738,11 @@ def query_siteLocation_parse(query_subparsers):
704
738
  query_siteLocation_parser = query_subparsers.add_parser('siteLocation',
705
739
  help='siteLocation local cli query',
706
740
  usage=get_help("query_siteLocation"))
707
-
708
741
  query_siteLocation_parser.add_argument('json', help='Variables in JSON format.')
709
742
  query_siteLocation_parser.add_argument('-accountID', help='Override the CATO_ACCOUNT_ID environment variable with this value.')
710
- query_siteLocation_parser.add_argument('-t', const=True, default=False, nargs='?',
711
- help='Print test request preview without sending api call')
712
- query_siteLocation_parser.add_argument('-v', const=True, default=False, nargs='?',
713
- help='Verbose output')
714
- query_siteLocation_parser.add_argument('-p', const=True, default=False, nargs='?',
715
- help='Pretty print')
743
+ query_siteLocation_parser.add_argument('-t', const=True, default=False, nargs='?', help='Print test request preview without sending api call')
744
+ query_siteLocation_parser.add_argument('-v', const=True, default=False, nargs='?', help='Verbose output')
745
+ query_siteLocation_parser.add_argument('-p', const=True, default=False, nargs='?', help='Pretty print')
716
746
  query_siteLocation_parser.set_defaults(func=querySiteLocation,operation_name='query.siteLocation')
717
747
  """
718
748
  parserPath = "../catocli/parsers/query_siteLocation"
@@ -740,12 +770,11 @@ def {parserName}_parse({operationType}_subparsers):
740
770
  cliDriverStr += f"""
741
771
  {parserName}_parser.add_argument('json', help='Variables in JSON format.')
742
772
  {parserName}_parser.add_argument('-accountID', help='Override the CATO_ACCOUNT_ID environment variable with this value.')
743
- {parserName}_parser.add_argument('-t', const=True, default=False, nargs='?',
744
- help='Print test request preview without sending api call')
745
- {parserName}_parser.add_argument('-v', const=True, default=False, nargs='?',
746
- help='Verbose output')
747
- {parserName}_parser.add_argument('-p', const=True, default=False, nargs='?',
748
- help='Pretty print')
773
+ {parserName}_parser.add_argument('-t', const=True, default=False, nargs='?', help='Print test request preview without sending api call')
774
+ {parserName}_parser.add_argument('-v', const=True, default=False, nargs='?', help='Verbose output')
775
+ {parserName}_parser.add_argument('-p', const=True, default=False, nargs='?', help='Pretty print')
776
+ {parserName}_parser.add_argument('-H', '--header', action='append', dest='headers', help='Add custom headers in "Key: Value" format. Can be used multiple times.')
777
+ {parserName}_parser.add_argument('--headers-file', dest='headers_file', help='Load headers from a file. Each line should contain a header in "Key: Value" format.')
749
778
  {parserName}_parser.set_defaults(func=createRequest,operation_name='{parserName.replace("_",".")}')
750
779
  """
751
780
  else:
@@ -772,12 +801,11 @@ def renderSubParser(subParser,parentParserPath):
772
801
  cliDriverStr += f"""
773
802
  {subParserPath}_parser.add_argument('json', help='Variables in JSON format.')
774
803
  {subParserPath}_parser.add_argument('-accountID', help='Override the CATO_ACCOUNT_ID environment variable with this value.')
775
- {subParserPath}_parser.add_argument('-t', const=True, default=False, nargs='?',
776
- help='Print test request preview without sending api call')
777
- {subParserPath}_parser.add_argument('-v', const=True, default=False, nargs='?',
778
- help='Verbose output')
779
- {subParserPath}_parser.add_argument('-p', const=True, default=False, nargs='?',
780
- help='Pretty print')
804
+ {subParserPath}_parser.add_argument('-t', const=True, default=False, nargs='?', help='Print test request preview without sending api call')
805
+ {subParserPath}_parser.add_argument('-v', const=True, default=False, nargs='?', help='Verbose output')
806
+ {subParserPath}_parser.add_argument('-p', const=True, default=False, nargs='?', help='Pretty print')
807
+ {subParserPath}_parser.add_argument('-H', '--header', action='append', dest='headers', help='Add custom headers in "Key: Value" format. Can be used multiple times.')
808
+ {subParserPath}_parser.add_argument('--headers-file', dest='headers_file', help='Load headers from a file. Each line should contain a header in "Key: Value" format.')
781
809
  {subParserPath}_parser.set_defaults(func=createRequest,operation_name='{subOperation["path"]}')
782
810
  """
783
811
  else: