teqconnect-cli 0.0.1__tar.gz → 0.1.0__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.
- teqconnect_cli-0.1.0/.gitignore +19 -0
- teqconnect_cli-0.1.0/PKG-INFO +13 -0
- teqconnect_cli-0.1.0/pyproject.toml +37 -0
- teqconnect_cli-0.1.0/teqconnect_cli/__init__.py +10 -0
- teqconnect_cli-0.1.0/teqconnect_cli/_output.py +116 -0
- teqconnect_cli-0.1.0/teqconnect_cli/_version.py +1 -0
- teqconnect_cli-0.1.0/teqconnect_cli/main.py +787 -0
- teqconnect_cli-0.1.0/teqconnect_cli/vpn_host.py +856 -0
- teqconnect_cli-0.0.1/.gitignore +0 -3
- teqconnect_cli-0.0.1/LICENSE +0 -202
- teqconnect_cli-0.0.1/PKG-INFO +0 -17
- teqconnect_cli-0.0.1/README.md +0 -5
- teqconnect_cli-0.0.1/pyproject.toml +0 -20
- teqconnect_cli-0.0.1/src/teqconnect_cli/__init__.py +0 -2
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
scripts/release/release.env
|
|
2
|
+
scripts/release/local/
|
|
3
|
+
scripts/release/history.jsonl
|
|
4
|
+
examples/*/.env
|
|
5
|
+
.DS_Store
|
|
6
|
+
__pycache__/
|
|
7
|
+
*.py[cod]
|
|
8
|
+
*.egg-info/
|
|
9
|
+
.venv/
|
|
10
|
+
dist/
|
|
11
|
+
build/
|
|
12
|
+
node_modules/
|
|
13
|
+
*.tsbuildinfo
|
|
14
|
+
.coverage
|
|
15
|
+
.pytest_cache/
|
|
16
|
+
.ruff_cache/
|
|
17
|
+
.mypy_cache/
|
|
18
|
+
*.tgz
|
|
19
|
+
.turbo/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: teqconnect-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The teq command-line interface for TeqConnect. Calls the Python SDK only.
|
|
5
|
+
Author: IO-TEQ
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Requires-Dist: cryptography>=50.0.2
|
|
9
|
+
Requires-Dist: jmespath>=1.1.0
|
|
10
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
11
|
+
Requires-Dist: rich>=15.0.0
|
|
12
|
+
Requires-Dist: teqconnect<0.2,>=0.1
|
|
13
|
+
Requires-Dist: typer>=0.29.2
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.33.0"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "teqconnect-cli"
|
|
7
|
+
description = "The teq command-line interface for TeqConnect. Calls the Python SDK only."
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
|
+
license = "Apache-2.0"
|
|
10
|
+
authors = [{ name = "IO-TEQ" }]
|
|
11
|
+
dynamic = ["version"]
|
|
12
|
+
dependencies = [
|
|
13
|
+
"teqconnect>=0.1,<0.2",
|
|
14
|
+
"typer>=0.29.2",
|
|
15
|
+
"rich>=15.0.0",
|
|
16
|
+
"jmespath>=1.1.0",
|
|
17
|
+
"pyyaml>=6.0.3",
|
|
18
|
+
"cryptography>=50.0.2",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.scripts]
|
|
22
|
+
teq = "teqconnect_cli.main:app"
|
|
23
|
+
|
|
24
|
+
[tool.uv.sources]
|
|
25
|
+
teqconnect = { workspace = true }
|
|
26
|
+
|
|
27
|
+
[tool.pytest.ini_options]
|
|
28
|
+
testpaths = ["tests"]
|
|
29
|
+
|
|
30
|
+
[tool.hatch.version]
|
|
31
|
+
path = "teqconnect_cli/_version.py"
|
|
32
|
+
|
|
33
|
+
[tool.hatch.build.targets.wheel]
|
|
34
|
+
packages = ["teqconnect_cli"]
|
|
35
|
+
|
|
36
|
+
[tool.hatch.build.targets.sdist]
|
|
37
|
+
include = ["teqconnect_cli"]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""teqconnect-cli: the ``teq`` command-line interface.
|
|
2
|
+
|
|
3
|
+
Every command is one call into the Python ``teqconnect`` SDK. This package never
|
|
4
|
+
imports ``httpx``, ``websockets``, or ``socket``: the SDK owns the only HTTP and
|
|
5
|
+
WebSocket paths.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from ._version import __version__
|
|
9
|
+
|
|
10
|
+
__all__ = ["__version__"]
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""Output rendering and the shared CLI state.
|
|
2
|
+
|
|
3
|
+
``emit`` unwraps the SDK return value, applies the ``--query`` JMESPath, and
|
|
4
|
+
prints it in the ``--output`` format. The value handed here is already the
|
|
5
|
+
unwrapped ``data`` (the SDK pipeline unwraps the envelope), so there is no
|
|
6
|
+
second HTTP call and no second unwrap. ``rich`` renders the table.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import sys
|
|
13
|
+
from dataclasses import dataclass, field
|
|
14
|
+
from typing import Any
|
|
15
|
+
|
|
16
|
+
import jmespath
|
|
17
|
+
import yaml
|
|
18
|
+
from rich.console import Console
|
|
19
|
+
from rich.table import Table
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class State:
|
|
24
|
+
profile: str = "default"
|
|
25
|
+
endpoint: str | None = None
|
|
26
|
+
output: str = "json"
|
|
27
|
+
query: str | None = None
|
|
28
|
+
debug: bool = False
|
|
29
|
+
org: str | None = None
|
|
30
|
+
extra: dict[str, Any] = field(default_factory=dict)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# One module-level state object; the Typer callback fills it before a command runs.
|
|
34
|
+
state = State()
|
|
35
|
+
|
|
36
|
+
_console = Console()
|
|
37
|
+
_err = Console(stderr=True)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def emit(value: Any, st: State) -> None:
|
|
41
|
+
"""Render ``value`` to stdout in the selected format after ``--query``."""
|
|
42
|
+
if st.query:
|
|
43
|
+
value = jmespath.search(st.query, value)
|
|
44
|
+
fmt = (st.output or "json").lower()
|
|
45
|
+
if fmt == "json":
|
|
46
|
+
_print_json(value)
|
|
47
|
+
elif fmt == "yaml":
|
|
48
|
+
_print_yaml(value)
|
|
49
|
+
elif fmt == "table":
|
|
50
|
+
_print_table(value)
|
|
51
|
+
elif fmt == "text":
|
|
52
|
+
_print_text(value)
|
|
53
|
+
else: # Unknown --output is bad usage.
|
|
54
|
+
_err.print(f"unknown --output: {st.output}")
|
|
55
|
+
raise SystemExit(2)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def debug(message: str, st: State) -> None:
|
|
59
|
+
"""Write a diagnostic line to stderr when ``--debug`` is set."""
|
|
60
|
+
if st.debug:
|
|
61
|
+
_err.print(f"[dim]debug:[/dim] {message}")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _print_json(value: Any) -> None:
|
|
65
|
+
sys.stdout.write(json.dumps(value, indent=2, default=str, sort_keys=False) + "\n")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _print_yaml(value: Any) -> None:
|
|
69
|
+
sys.stdout.write(yaml.safe_dump(_plain(value), sort_keys=False, default_flow_style=False))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _print_text(value: Any) -> None:
|
|
73
|
+
if isinstance(value, (dict, list)):
|
|
74
|
+
sys.stdout.write(json.dumps(value, default=str) + "\n")
|
|
75
|
+
elif value is None:
|
|
76
|
+
sys.stdout.write("\n")
|
|
77
|
+
else:
|
|
78
|
+
sys.stdout.write(str(value) + "\n")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _print_table(value: Any) -> None:
|
|
82
|
+
rows = value if isinstance(value, list) else [value]
|
|
83
|
+
rows = [r for r in rows if isinstance(r, dict)]
|
|
84
|
+
if not rows:
|
|
85
|
+
_print_text(value)
|
|
86
|
+
return
|
|
87
|
+
columns: list[str] = []
|
|
88
|
+
for row in rows:
|
|
89
|
+
for key in row:
|
|
90
|
+
if key not in columns:
|
|
91
|
+
columns.append(key)
|
|
92
|
+
table = Table(show_header=True, header_style="bold")
|
|
93
|
+
for column in columns:
|
|
94
|
+
table.add_column(column)
|
|
95
|
+
for row in rows:
|
|
96
|
+
table.add_row(*[_cell(row.get(column)) for column in columns])
|
|
97
|
+
_console.print(table)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _cell(value: Any) -> str:
|
|
101
|
+
if value is None:
|
|
102
|
+
return ""
|
|
103
|
+
if isinstance(value, (dict, list)):
|
|
104
|
+
return json.dumps(value, default=str)
|
|
105
|
+
return str(value)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _plain(value: Any) -> Any:
|
|
109
|
+
"""Coerce to plain containers so yaml does not emit Python object tags."""
|
|
110
|
+
if isinstance(value, dict):
|
|
111
|
+
return {k: _plain(v) for k, v in value.items()}
|
|
112
|
+
if isinstance(value, (list, tuple)):
|
|
113
|
+
return [_plain(v) for v in value]
|
|
114
|
+
if isinstance(value, (str, int, float, bool)) or value is None:
|
|
115
|
+
return value
|
|
116
|
+
return str(value)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|