netbox-super-cli 1.0.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.
Files changed (71) hide show
  1. netbox_super_cli-1.0.0.dist-info/METADATA +182 -0
  2. netbox_super_cli-1.0.0.dist-info/RECORD +71 -0
  3. netbox_super_cli-1.0.0.dist-info/WHEEL +4 -0
  4. netbox_super_cli-1.0.0.dist-info/entry_points.txt +3 -0
  5. netbox_super_cli-1.0.0.dist-info/licenses/LICENSE +201 -0
  6. nsc/__init__.py +5 -0
  7. nsc/__main__.py +6 -0
  8. nsc/_version.py +3 -0
  9. nsc/aliases/__init__.py +24 -0
  10. nsc/aliases/resolver.py +112 -0
  11. nsc/auth/__init__.py +5 -0
  12. nsc/auth/verify.py +143 -0
  13. nsc/builder/__init__.py +5 -0
  14. nsc/builder/build.py +514 -0
  15. nsc/cache/__init__.py +5 -0
  16. nsc/cache/store.py +295 -0
  17. nsc/cli/__init__.py +1 -0
  18. nsc/cli/aliases_commands.py +264 -0
  19. nsc/cli/app.py +291 -0
  20. nsc/cli/cache_commands.py +159 -0
  21. nsc/cli/commands_dump.py +57 -0
  22. nsc/cli/config_commands.py +156 -0
  23. nsc/cli/globals.py +65 -0
  24. nsc/cli/handlers.py +660 -0
  25. nsc/cli/init_commands.py +95 -0
  26. nsc/cli/login_commands.py +265 -0
  27. nsc/cli/profiles_commands.py +256 -0
  28. nsc/cli/registration.py +465 -0
  29. nsc/cli/runtime.py +290 -0
  30. nsc/cli/skill_commands.py +186 -0
  31. nsc/cli/writes/__init__.py +10 -0
  32. nsc/cli/writes/apply.py +177 -0
  33. nsc/cli/writes/bulk.py +231 -0
  34. nsc/cli/writes/coercion.py +9 -0
  35. nsc/cli/writes/confirmation.py +96 -0
  36. nsc/cli/writes/input.py +358 -0
  37. nsc/cli/writes/preflight.py +182 -0
  38. nsc/config/__init__.py +23 -0
  39. nsc/config/loader.py +69 -0
  40. nsc/config/models.py +54 -0
  41. nsc/config/settings.py +36 -0
  42. nsc/config/writer.py +207 -0
  43. nsc/http/__init__.py +6 -0
  44. nsc/http/audit.py +183 -0
  45. nsc/http/client.py +365 -0
  46. nsc/http/errors.py +35 -0
  47. nsc/http/retry.py +90 -0
  48. nsc/model/__init__.py +23 -0
  49. nsc/model/command_model.py +125 -0
  50. nsc/output/__init__.py +1 -0
  51. nsc/output/csv_.py +34 -0
  52. nsc/output/errors.py +346 -0
  53. nsc/output/explain.py +194 -0
  54. nsc/output/flatten.py +25 -0
  55. nsc/output/headers.py +9 -0
  56. nsc/output/json_.py +21 -0
  57. nsc/output/jsonl.py +21 -0
  58. nsc/output/render.py +47 -0
  59. nsc/output/table.py +50 -0
  60. nsc/output/yaml_.py +28 -0
  61. nsc/schema/__init__.py +1 -0
  62. nsc/schema/hashing.py +24 -0
  63. nsc/schema/loader.py +66 -0
  64. nsc/schema/models.py +109 -0
  65. nsc/schema/source.py +120 -0
  66. nsc/schemas/__init__.py +1 -0
  67. nsc/schemas/bundled/__init__.py +1 -0
  68. nsc/schemas/bundled/manifest.yaml +5 -0
  69. nsc/schemas/bundled/netbox-4.6.0-beta2.json.gz +0 -0
  70. nsc/skill/__init__.py +35 -0
  71. skills/netbox-super-cli/SKILL.md +127 -0
nsc/cli/globals.py ADDED
@@ -0,0 +1,65 @@
1
+ """Global option definitions and the RuntimeContext factory."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import sys
7
+ from dataclasses import dataclass
8
+
9
+ from nsc.cli.runtime import (
10
+ CLIOverrides,
11
+ NoProfileError,
12
+ ResolvedProfile,
13
+ RuntimeContext,
14
+ UnknownProfileError,
15
+ resolve_profile,
16
+ )
17
+ from nsc.config import default_paths
18
+ from nsc.config.loader import ConfigParseError
19
+ from nsc.config.models import Config
20
+ from nsc.http.client import NetBoxClient
21
+ from nsc.output.render import select_format
22
+ from nsc.schema.source import SchemaSourceError, resolve_command_model
23
+
24
+
25
+ @dataclass
26
+ class GlobalState:
27
+ overrides: CLIOverrides
28
+ config: Config
29
+ debug: bool
30
+
31
+
32
+ def build_runtime_context(state: GlobalState) -> RuntimeContext:
33
+ profile = resolve_profile(state.config, state.overrides, env=os.environ)
34
+ paths = default_paths()
35
+ model = resolve_command_model(
36
+ paths=paths, profile=profile, schema_override=state.overrides.schema_override
37
+ )
38
+ output = select_format(
39
+ cli_value=state.overrides.output,
40
+ env_value=os.environ.get("NSC_OUTPUT"),
41
+ is_tty=sys.stdout.isatty(),
42
+ default=state.config.defaults.output,
43
+ )
44
+ client = NetBoxClient(profile, debug=state.debug) # type: ignore[arg-type]
45
+ return RuntimeContext(
46
+ resolved_profile=profile,
47
+ config=state.config,
48
+ command_model=model,
49
+ client=client,
50
+ output_format=output,
51
+ debug=state.debug,
52
+ page_size=state.config.defaults.page_size,
53
+ )
54
+
55
+
56
+ __all__ = [
57
+ "ConfigParseError",
58
+ "GlobalState",
59
+ "NetBoxClient",
60
+ "NoProfileError",
61
+ "ResolvedProfile",
62
+ "SchemaSourceError",
63
+ "UnknownProfileError",
64
+ "build_runtime_context",
65
+ ]