centralcli 2.3.2__tar.gz → 2.3.4__tar.gz

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.
Files changed (50) hide show
  1. {centralcli-2.3.2 → centralcli-2.3.4}/PKG-INFO +1 -1
  2. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/cli.py +73 -1
  3. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/cliassign.py +1 -0
  4. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clibatch.py +1 -1
  5. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clicommon.py +8 -4
  6. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/constants.py +5 -0
  7. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/objects.py +2 -1
  8. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/wh_proxy.py +1 -1
  9. {centralcli-2.3.2 → centralcli-2.3.4}/pyproject.toml +1 -1
  10. {centralcli-2.3.2 → centralcli-2.3.4}/LICENSE +0 -0
  11. {centralcli-2.3.2 → centralcli-2.3.4}/README.md +0 -0
  12. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/__init__.py +0 -0
  13. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/boilerplate/README.md +0 -0
  14. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/boilerplate/allcalls.py +0 -0
  15. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/caas.py +0 -0
  16. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/cache.py +0 -0
  17. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/central.py +0 -0
  18. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/cleaner.py +0 -0
  19. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/cliadd.py +0 -0
  20. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clicaas.py +0 -0
  21. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/cliclone.py +0 -0
  22. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clidel.py +0 -0
  23. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clikick.py +0 -0
  24. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clirefresh.py +0 -0
  25. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clirename.py +0 -0
  26. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clishow.py +0 -0
  27. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clishowbranch.py +0 -0
  28. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clishowfirmware.py +0 -0
  29. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clishowospf.py +0 -0
  30. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clishowoverlay.py +0 -0
  31. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clishowtshoot.py +0 -0
  32. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clishowwids.py +0 -0
  33. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clitest.py +0 -0
  34. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/clitshoot.py +0 -0
  35. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/cliunassign.py +0 -0
  36. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/cliupdate.py +0 -0
  37. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/cliupgrade.py +0 -0
  38. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/config.py +0 -0
  39. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/exceptions.py +0 -0
  40. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/logger.py +0 -0
  41. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/models.py +0 -0
  42. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/render.py +0 -0
  43. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/response.py +0 -0
  44. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/setup.py +0 -0
  45. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/static/favicon.ico +0 -0
  46. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/strings.py +0 -0
  47. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/utils.py +0 -0
  48. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/vscodeargs.py +0 -0
  49. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/wh2snow.py +0 -0
  50. {centralcli-2.3.2 → centralcli-2.3.4}/centralcli/wh_proxy_service.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: centralcli
3
- Version: 2.3.2
3
+ Version: 2.3.4
4
4
  Summary: A CLI for interacting with Aruba Central (Cloud Management Platform). Facilitates bulk imports, exports, reporting. A handy tool if you have devices managed by Aruba Central.
5
5
  Home-page: https://github.com/Pack3tL0ss/central-api-cli
6
6
  License: MIT
@@ -42,7 +42,7 @@ except (ImportError, ModuleNotFoundError) as e:
42
42
 
43
43
  from centralcli.cache import CentralObject
44
44
  from centralcli.central import CentralApi # noqa
45
- from centralcli.constants import (BlinkArgs, BounceArgs, IdenMetaVars, StartArgs, ResetArgs)
45
+ from centralcli.constants import (BlinkArgs, BounceArgs, IdenMetaVars, StartArgs, ResetArgs, EnableDisableArgs)
46
46
 
47
47
  iden = IdenMetaVars()
48
48
 
@@ -715,6 +715,78 @@ def unarchive(
715
715
  cli.display_results(resp, tablefmt="action")
716
716
 
717
717
 
718
+ @app.command(hidden=True)
719
+ def enable(
720
+ what: EnableDisableArgs = typer.Argument("auto-sub"),
721
+ services: List[cli.cache.LicenseTypes] = typer.Argument(..., show_default=False),
722
+ yes: bool = typer.Option(False, "-Y", "-y", help="Bypass confirmation prompts - Assume Yes"),
723
+ debug: bool = typer.Option(False, "--debug", envvar="ARUBACLI_DEBUG", help="Enable Additional Debug Logging",),
724
+ default: bool = typer.Option(False, "-d", is_flag=True, help="Use default central account", show_default=False,),
725
+ account: str = typer.Option("central_info",
726
+ envvar="ARUBACLI_ACCOUNT",
727
+ help="The Aruba Central Account to use (must be defined in the config)",
728
+ autocompletion=cli.cache.account_completion),
729
+ ) -> None:
730
+ """Enable auto subscribe for service.
731
+
732
+ Enabling auto subscribe sets the level (i.e. foundation/advanced) for all devices of the same type as the subscription provided.
733
+ i.e. `enable auto-sub advanced-switch-6300` will enable auto subscribe for all switch tiers (6100, 6200, etc)
734
+ """
735
+
736
+ _msg = f"[bright_green]Enable[/] auto-subscribe for license"
737
+ if len(services) > 1:
738
+ _svc_msg = '\n '.join([s.name for s in services])
739
+ _msg = f'{_msg}s:\n {_svc_msg}\n'
740
+ else:
741
+ svc = services[0]
742
+ _msg = f'{_msg} {svc.name}'
743
+ print(_msg)
744
+ print('\n[dark_orange]!![/] Enabling auto-subscribe applies the specified tier (i.e. foundation/advanced) for [green bold]all[/] devices of the same type.')
745
+ print(f'[cyan]enable auto-sub advanced-switch-6300[/] will result in [green bold]all[/] switch models being set to auto-subscribe the advanced license appropriate for that model.')
746
+ print(f'Not just the 6300 models.')
747
+ if yes or typer.confirm("\nProceed?", abort=True):
748
+ services = [s.name for s in services]
749
+
750
+ resp = cli.central.request(cli.central.enable_auto_subscribe, services=services)
751
+ cli.display_results(resp, tablefmt="action")
752
+
753
+
754
+ @app.command(hidden=True)
755
+ def disable(
756
+ what: EnableDisableArgs = typer.Argument("auto-sub"),
757
+ services: List[cli.cache.LicenseTypes] = typer.Argument(..., show_default=False),
758
+ yes: bool = typer.Option(False, "-Y", "-y", help="Bypass confirmation prompts - Assume Yes"),
759
+ debug: bool = typer.Option(False, "--debug", envvar="ARUBACLI_DEBUG", help="Enable Additional Debug Logging",),
760
+ default: bool = typer.Option(False, "-d", is_flag=True, help="Use default central account", show_default=False,),
761
+ account: str = typer.Option("central_info",
762
+ envvar="ARUBACLI_ACCOUNT",
763
+ help="The Aruba Central Account to use (must be defined in the config)",
764
+ autocompletion=cli.cache.account_completion),
765
+ ) -> None:
766
+ """Disable auto subscribe for service.
767
+
768
+ Disabling auto subscribe removes auto-subscribe for all models of the same type.
769
+ i.e. `disable auto-sub advanced-switch-6300` will disable auto subscribe for all switch tiers (6100, 6200, etc)
770
+ """
771
+
772
+ _msg = f"[bright_green]Disable[/] auto-subscribe for license"
773
+ if len(services) > 1:
774
+ _svc_msg = '\n '.join([s.name for s in services])
775
+ _msg = f'{_msg}s:\n {_svc_msg}\n'
776
+ else:
777
+ svc = services[0]
778
+ _msg = f'{_msg} {svc.name}'
779
+ print(_msg)
780
+ print('\n[dark_orange]!![/] Disabling auto subscribe removes auto-subscribe for all models of the same type.')
781
+ print(f'[cyan]disable auto-sub advanced-switch-6300[/] will result in auto-subscribe being disabled for [green bold]all[/] switch models.')
782
+ print(f'Not just the 6300.')
783
+ if yes or typer.confirm("\nProceed?", abort=True):
784
+ services = [s.name for s in services]
785
+
786
+ resp = cli.central.request(cli.central.enable_auto_subscribe, services=services)
787
+ cli.display_results(resp, tablefmt="action")
788
+
789
+
718
790
  @app.command(short_help="convert j2 templates")
719
791
  def convert(
720
792
  template: Path = typer.Argument(..., help="j2 template to convert", exists=True),
@@ -24,6 +24,7 @@ except (ImportError, ModuleNotFoundError) as e:
24
24
  app = typer.Typer()
25
25
 
26
26
 
27
+ # TODO consider removing auto option as we've added enable/disable auto-sub ...
27
28
  @app.command()
28
29
  def license(
29
30
  license: cli.cache.LicenseTypes = typer.Argument(..., show_default=False),
@@ -1069,7 +1069,7 @@ def batch_delete_devices(data: Union[list, dict], *, ui_only: bool = False, yes:
1069
1069
  if not all([r.ok for r in batch_resp]):
1070
1070
  console.print("[bright_red]A Failure occured aborting remaining actions.[/]")
1071
1071
  console.print("[italic]Cache has not been updated, [cyan]cencli show all -v[/ cyan] will result in a full cache update.[/ italic]")
1072
- cli.display_results(batch_resp, exit_on_fail=True, caption="Re-run command to perform remaining actions.")
1072
+ cli.display_results(batch_resp, exit_on_fail=True, caption="Re-run command to perform remaining actions.", tablefmt="action")
1073
1073
 
1074
1074
  if not delayed_mon_del_reqs and not cop_del_reqs:
1075
1075
  # if all reqs OK cache is updated by deleting specific items, otherwise it's a full cache refresh
@@ -177,14 +177,18 @@ class CLICommon:
177
177
  if ctx is not None and ctx.resilient_parsing: # tab completion, return without validating
178
178
  return
179
179
 
180
- current = pkg_resources.get_distribution('centralcli').version
180
+ try:
181
+ current = pkg_resources.get_distribution('centralcli').version
182
+ except pkg_resources.DistributionNotFound:
183
+ current = "0.0.0 !! Unable to gather version"
181
184
  resp = self.central.request(self.central.get, "https://pypi.org/pypi/centralcli/json")
182
185
  if not resp:
183
186
  print(current)
184
187
  else:
185
- major = max([int(str(k).split(".")[0]) for k in resp.output["releases"].keys() if "a" not in k and k.count(".") < 2])
186
- minor = max([int(str(k).split(".")[1]) for k in resp.output["releases"].keys() if "a" not in k and k.count(".") == 1 and int(str(k).split(".")[0]) == major])
187
- latest = f'{major}.{minor}'
188
+ # major = max([int(str(k).split(".")[0]) for k in resp.output["releases"].keys() if "a" not in k and k.count(".") < 3])
189
+ # minor = max([int(str(k).split(".")[1]) for k in resp.output["releases"].keys() if "a" not in k and k.count(".") == 1 and int(str(k).split(".")[0]) == major])
190
+ # latest = f'{major}.{minor}'
191
+ latest = max(resp.output["releases"])
188
192
  msg = "[bold bright_green]centralcli[/] "
189
193
  msg += 'A CLI app for interacting with Aruba Central Cloud Management Platform.\n'
190
194
  msg += f'Brought to you by [cyan]{resp.output["info"]["author"]}[/]\n\n'
@@ -295,6 +295,11 @@ class BatchRenameArgs(str, Enum):
295
295
  groups = "groups"
296
296
 
297
297
 
298
+ class EnableDisableArgs(str, Enum):
299
+ auto_sub = "auto-sub"
300
+
301
+
302
+
298
303
  class DhcpArgs(str, Enum):
299
304
  clients = "clients"
300
305
  server = "server"
@@ -6,6 +6,7 @@ from typing import Literal
6
6
  from json import JSONEncoder
7
7
  from enum import Enum
8
8
  import pendulum
9
+ from pathlib import Path
9
10
 
10
11
 
11
12
  TimeFormat = Literal["day-datetime", "durwords", "durwords-short", "timediff", "mdyt", "log"]
@@ -122,5 +123,5 @@ class Encoder(JSONEncoder):
122
123
  A Custom JSON Encoder to handle custom DateTime object during JSON serialization.
123
124
  """
124
125
  def default(self, o):
125
- return o if not isinstance(o, DateTime) else str(o)
126
+ return o if not isinstance(o, DateTime) and not isinstance(o, Path) else str(o)
126
127
 
@@ -254,7 +254,7 @@ def verify_header_auth(data: dict, svc: str, sig: str, ts: str, del_id: str):
254
254
  received from Aruba Central via Webhooks
255
255
  """
256
256
  # Token obtained from Aruba Central Webhooks page as provided in the input
257
- token = config.tokens["webhook_token"]
257
+ token = config.tokens.get("webhook_token")
258
258
  if token:
259
259
  log.warning(
260
260
  f"Deprication Warning: webhook_token is depricated and will be removed in a future release. webhook now has it's own key under the account, refer to documentation to adjust config.yaml",
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "centralcli"
3
- version = "2.3.2"
3
+ version = "2.3.4"
4
4
  description = "A CLI for interacting with Aruba Central (Cloud Management Platform). Facilitates bulk imports, exports, reporting. A handy tool if you have devices managed by Aruba Central."
5
5
  license = "MIT"
6
6
  authors = ["Wade Wells (Pack3tL0ss) <wade@consolepi.org>"]
File without changes
File without changes