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.
- netbox_super_cli-1.0.0.dist-info/METADATA +182 -0
- netbox_super_cli-1.0.0.dist-info/RECORD +71 -0
- netbox_super_cli-1.0.0.dist-info/WHEEL +4 -0
- netbox_super_cli-1.0.0.dist-info/entry_points.txt +3 -0
- netbox_super_cli-1.0.0.dist-info/licenses/LICENSE +201 -0
- nsc/__init__.py +5 -0
- nsc/__main__.py +6 -0
- nsc/_version.py +3 -0
- nsc/aliases/__init__.py +24 -0
- nsc/aliases/resolver.py +112 -0
- nsc/auth/__init__.py +5 -0
- nsc/auth/verify.py +143 -0
- nsc/builder/__init__.py +5 -0
- nsc/builder/build.py +514 -0
- nsc/cache/__init__.py +5 -0
- nsc/cache/store.py +295 -0
- nsc/cli/__init__.py +1 -0
- nsc/cli/aliases_commands.py +264 -0
- nsc/cli/app.py +291 -0
- nsc/cli/cache_commands.py +159 -0
- nsc/cli/commands_dump.py +57 -0
- nsc/cli/config_commands.py +156 -0
- nsc/cli/globals.py +65 -0
- nsc/cli/handlers.py +660 -0
- nsc/cli/init_commands.py +95 -0
- nsc/cli/login_commands.py +265 -0
- nsc/cli/profiles_commands.py +256 -0
- nsc/cli/registration.py +465 -0
- nsc/cli/runtime.py +290 -0
- nsc/cli/skill_commands.py +186 -0
- nsc/cli/writes/__init__.py +10 -0
- nsc/cli/writes/apply.py +177 -0
- nsc/cli/writes/bulk.py +231 -0
- nsc/cli/writes/coercion.py +9 -0
- nsc/cli/writes/confirmation.py +96 -0
- nsc/cli/writes/input.py +358 -0
- nsc/cli/writes/preflight.py +182 -0
- nsc/config/__init__.py +23 -0
- nsc/config/loader.py +69 -0
- nsc/config/models.py +54 -0
- nsc/config/settings.py +36 -0
- nsc/config/writer.py +207 -0
- nsc/http/__init__.py +6 -0
- nsc/http/audit.py +183 -0
- nsc/http/client.py +365 -0
- nsc/http/errors.py +35 -0
- nsc/http/retry.py +90 -0
- nsc/model/__init__.py +23 -0
- nsc/model/command_model.py +125 -0
- nsc/output/__init__.py +1 -0
- nsc/output/csv_.py +34 -0
- nsc/output/errors.py +346 -0
- nsc/output/explain.py +194 -0
- nsc/output/flatten.py +25 -0
- nsc/output/headers.py +9 -0
- nsc/output/json_.py +21 -0
- nsc/output/jsonl.py +21 -0
- nsc/output/render.py +47 -0
- nsc/output/table.py +50 -0
- nsc/output/yaml_.py +28 -0
- nsc/schema/__init__.py +1 -0
- nsc/schema/hashing.py +24 -0
- nsc/schema/loader.py +66 -0
- nsc/schema/models.py +109 -0
- nsc/schema/source.py +120 -0
- nsc/schemas/__init__.py +1 -0
- nsc/schemas/bundled/__init__.py +1 -0
- nsc/schemas/bundled/manifest.yaml +5 -0
- nsc/schemas/bundled/netbox-4.6.0-beta2.json.gz +0 -0
- nsc/skill/__init__.py +35 -0
- 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
|
+
]
|