hookstride-cli 0.2.1__py3-none-any.whl → 0.3.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.
- hookstride_cli/__init__.py +1 -1
- hookstride_cli/console.py +18 -14
- hookstride_cli/main.py +465 -118
- {hookstride_cli-0.2.1.dist-info → hookstride_cli-0.3.0.dist-info}/METADATA +19 -14
- hookstride_cli-0.3.0.dist-info/RECORD +7 -0
- hookstride_cli-0.2.1.dist-info/RECORD +0 -7
- {hookstride_cli-0.2.1.dist-info → hookstride_cli-0.3.0.dist-info}/WHEEL +0 -0
- {hookstride_cli-0.2.1.dist-info → hookstride_cli-0.3.0.dist-info}/entry_points.txt +0 -0
hookstride_cli/__init__.py
CHANGED
hookstride_cli/console.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
"""Interactive
|
|
1
|
+
"""Interactive Hookstride console with allowlisted project and destination writes.
|
|
2
2
|
|
|
3
|
-
The console
|
|
4
|
-
|
|
5
|
-
and stores no history on disk.
|
|
3
|
+
The console never executes shell commands, retains tokens only in memory,
|
|
4
|
+
and stores no command history on disk.
|
|
6
5
|
"""
|
|
7
6
|
|
|
8
7
|
from __future__ import annotations
|
|
@@ -25,11 +24,11 @@ from typer.main import get_command
|
|
|
25
24
|
from . import main as cli
|
|
26
25
|
|
|
27
26
|
# Only these typed commands may execute through the console.
|
|
28
|
-
#
|
|
29
|
-
|
|
27
|
+
# Write actions are intentionally allowlisted, never automatically unlocked.
|
|
28
|
+
ALLOWED_COMMANDS: dict[str, set[str]] = {
|
|
30
29
|
"auth": {"status"},
|
|
31
|
-
"projects": {"list", "use"},
|
|
32
|
-
"destinations": {"list"},
|
|
30
|
+
"projects": {"list", "use", "create", "update"},
|
|
31
|
+
"destinations": {"list", "create", "update"},
|
|
33
32
|
"keys": {"list"},
|
|
34
33
|
"events": {"list", "show"},
|
|
35
34
|
"billing": {"status", "history"},
|
|
@@ -38,7 +37,7 @@ READ_COMMANDS: dict[str, set[str]] = {
|
|
|
38
37
|
}
|
|
39
38
|
ROOT_COMMANDS = {"status", "stats"}
|
|
40
39
|
|
|
41
|
-
# Aliases that feel like a familiar operator console
|
|
40
|
+
# Aliases that feel like a familiar operator console.
|
|
42
41
|
SHOW_TARGETS: dict[str, tuple[str, ...] | None] = {
|
|
43
42
|
"options": None,
|
|
44
43
|
"projects": ("projects", "list"),
|
|
@@ -72,6 +71,8 @@ COMMAND_COMPLETIONS = sorted(
|
|
|
72
71
|
*SAFE_HISTORY_COMMANDS,
|
|
73
72
|
"use ", "projects use ", "events show ", "events list --status ",
|
|
74
73
|
"events list --origin ", "events list --page ", "set project ",
|
|
74
|
+
"projects create --name ", "projects update ",
|
|
75
|
+
"destinations create --name ", "destinations update ",
|
|
75
76
|
"set env ", "json ", "show ", "auth ",
|
|
76
77
|
}
|
|
77
78
|
)
|
|
@@ -194,6 +195,8 @@ class HookstrideConsole:
|
|
|
194
195
|
"[bold]help[/bold] Show console help\n"
|
|
195
196
|
"[bold]show options[/bold] Display environment, project and authentication\n"
|
|
196
197
|
"[bold]show projects[/bold] List accessible projects\n"
|
|
198
|
+
"[bold]projects create --name N --account UUID[/bold] Create a project\n"
|
|
199
|
+
"[bold]projects update UUID --name N[/bold] Rename a project\n"
|
|
197
200
|
"[bold]use UUID[/bold] Select a project (also saves preference)\n"
|
|
198
201
|
"[bold]back[/bold] Leave the active project context\n"
|
|
199
202
|
"[bold]set env dev[/bold] Switch to development API\n"
|
|
@@ -202,6 +205,8 @@ class HookstrideConsole:
|
|
|
202
205
|
"[bold]auth logout[/bold] Clear the current environment's session token\n"
|
|
203
206
|
"[bold]auth status[/bold] Validate current token\n"
|
|
204
207
|
"[bold]show destinations[/bold] Inspect outgoing webhooks\n"
|
|
208
|
+
"[bold]destinations create --name N --url HTTPS_URL[/bold] Add receiver\n"
|
|
209
|
+
"[bold]destinations update UUID --pause[/bold] Pause a receiver\n"
|
|
205
210
|
"[bold]show events[/bold] View recent events\n"
|
|
206
211
|
"[bold]events list --status failed[/bold] Filter delivery history\n"
|
|
207
212
|
"[bold]events show UUID[/bold] Inspect a delivery and attempts\n"
|
|
@@ -223,7 +228,6 @@ class HookstrideConsole:
|
|
|
223
228
|
["API", self.session.origin],
|
|
224
229
|
["Project", project],
|
|
225
230
|
["Authenticated token", "configured" if self._current_token() else "missing"],
|
|
226
|
-
["Mode", "read-only"],
|
|
227
231
|
]
|
|
228
232
|
cli._table(_FakeContext(self.session), "Session options", ["Setting", "Value"], rows)
|
|
229
233
|
|
|
@@ -294,7 +298,7 @@ class HookstrideConsole:
|
|
|
294
298
|
self._write("[green]✓[/green] Signed out for this console environment.")
|
|
295
299
|
|
|
296
300
|
def _execute_cli(self, args: list[str], *, json_output: bool = False) -> None:
|
|
297
|
-
"""Invoke
|
|
301
|
+
"""Invoke explicitly allowed Click/Typer commands, never a shell."""
|
|
298
302
|
if not _allowed_cli(args):
|
|
299
303
|
raise cli.CLIError("Unknown or unavailable command. Type 'help'.")
|
|
300
304
|
group = args[0]
|
|
@@ -382,7 +386,7 @@ class HookstrideConsole:
|
|
|
382
386
|
|
|
383
387
|
def run(self) -> None:
|
|
384
388
|
self._write(
|
|
385
|
-
"\n[bold cyan]HOOKSTRIDE[/bold cyan] [dim]CONSOLE
|
|
389
|
+
f"\n[bold cyan]HOOKSTRIDE[/bold cyan] [dim]CONSOLE v{cli.VERSION}[/dim]\n"
|
|
386
390
|
"[dim]Type 'help' for commands, 'auth login' for a token, "
|
|
387
391
|
"or 'exit' to quit.[/dim]\n"
|
|
388
392
|
)
|
|
@@ -431,8 +435,8 @@ def _allowed_cli(parts: list[str]) -> bool:
|
|
|
431
435
|
return len(parts) == 1
|
|
432
436
|
return (
|
|
433
437
|
len(parts) >= 2
|
|
434
|
-
and parts[0] in
|
|
435
|
-
and parts[1] in
|
|
438
|
+
and parts[0] in ALLOWED_COMMANDS
|
|
439
|
+
and parts[1] in ALLOWED_COMMANDS[parts[0]]
|
|
436
440
|
)
|
|
437
441
|
|
|
438
442
|
|
hookstride_cli/main.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"""Hookstride CLI:
|
|
1
|
+
"""Hookstride CLI: project-scoped Control API management.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Commands use Control API tokens. This module never persists a token.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
from __future__ import annotations
|
|
@@ -24,20 +24,22 @@ from rich.markup import escape
|
|
|
24
24
|
from rich.panel import Panel
|
|
25
25
|
from rich.text import Text
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
from . import __version__
|
|
28
|
+
|
|
29
|
+
VERSION = __version__
|
|
28
30
|
ORIGINS = {
|
|
29
|
-
"dev": "https://api-dev.hookstride.
|
|
30
|
-
"production": "https://api.hookstride.
|
|
31
|
+
"dev": "https://api-dev.hookstride.com",
|
|
32
|
+
"production": "https://api.hookstride.com",
|
|
31
33
|
}
|
|
32
34
|
app = typer.Typer(
|
|
33
|
-
help="Hookstride ·
|
|
35
|
+
help="Hookstride · manage projects and webhook destinations.",
|
|
34
36
|
add_completion=False,
|
|
35
37
|
no_args_is_help=False,
|
|
36
38
|
pretty_exceptions_show_locals=False,
|
|
37
39
|
)
|
|
38
40
|
auth_app = typer.Typer(help="Check Control API authentication.")
|
|
39
|
-
projects_app = typer.Typer(help="List and select
|
|
40
|
-
destinations_app = typer.Typer(help="
|
|
41
|
+
projects_app = typer.Typer(help="List, create, update and select workspace projects.")
|
|
42
|
+
destinations_app = typer.Typer(help="List, create and update webhook destinations.")
|
|
41
43
|
events_app = typer.Typer(help="Inspect delivery history and attempts.")
|
|
42
44
|
billing_app = typer.Typer(help="Inspect project-isolated billing.")
|
|
43
45
|
incoming_app = typer.Typer(help="Inspect incoming webhook sources.")
|
|
@@ -59,8 +61,12 @@ class CLIError(Exception):
|
|
|
59
61
|
|
|
60
62
|
class Session:
|
|
61
63
|
def __init__(
|
|
62
|
-
self,
|
|
63
|
-
|
|
64
|
+
self,
|
|
65
|
+
environment: str,
|
|
66
|
+
api_url: str | None,
|
|
67
|
+
project: str | None,
|
|
68
|
+
json_output: bool,
|
|
69
|
+
no_color: bool,
|
|
64
70
|
) -> None:
|
|
65
71
|
if environment not in ORIGINS:
|
|
66
72
|
raise CLIError("Choose --env dev or --env production.")
|
|
@@ -69,7 +75,8 @@ class Session:
|
|
|
69
75
|
self.project = _uuid(project) if project else None
|
|
70
76
|
self.json_output = json_output
|
|
71
77
|
self.console = Console(
|
|
72
|
-
stderr=False,
|
|
78
|
+
stderr=False,
|
|
79
|
+
no_color=no_color or json_output,
|
|
73
80
|
force_terminal=False if json_output else None,
|
|
74
81
|
)
|
|
75
82
|
|
|
@@ -81,10 +88,17 @@ def _origin(value: str) -> str:
|
|
|
81
88
|
port = parts.port
|
|
82
89
|
hostname = parts.hostname
|
|
83
90
|
except ValueError:
|
|
84
|
-
raise CLIError(
|
|
91
|
+
raise CLIError(
|
|
92
|
+
"Invalid API origin. Specify a hostname and valid port."
|
|
93
|
+
) from None
|
|
85
94
|
if (
|
|
86
|
-
not hostname
|
|
87
|
-
or
|
|
95
|
+
not hostname
|
|
96
|
+
or port == 0
|
|
97
|
+
or parts.username
|
|
98
|
+
or parts.password
|
|
99
|
+
or parts.query
|
|
100
|
+
or parts.fragment
|
|
101
|
+
or parts.path not in ("", "/")
|
|
88
102
|
):
|
|
89
103
|
raise CLIError("API URL must be an origin, without path, credentials or query.")
|
|
90
104
|
if parts.scheme != "https" and not (
|
|
@@ -98,13 +112,15 @@ def _uuid(value: str) -> str:
|
|
|
98
112
|
try:
|
|
99
113
|
return str(uuid.UUID(value))
|
|
100
114
|
except (ValueError, AttributeError) as exc:
|
|
101
|
-
raise CLIError("Expected a valid
|
|
115
|
+
raise CLIError("Expected a valid UUID.") from exc
|
|
102
116
|
|
|
103
117
|
|
|
104
118
|
def _config_file() -> Path:
|
|
105
119
|
configured = os.environ.get("HOOKSTRIDE_CONFIG_FILE")
|
|
106
|
-
return
|
|
107
|
-
Path.
|
|
120
|
+
return (
|
|
121
|
+
Path(configured).expanduser()
|
|
122
|
+
if configured
|
|
123
|
+
else (Path.home() / ".config" / "hookstride" / "settings.json")
|
|
108
124
|
)
|
|
109
125
|
|
|
110
126
|
|
|
@@ -156,7 +172,9 @@ def _project(ctx: typer.Context) -> str:
|
|
|
156
172
|
saved = _read_config().get("projects", {})
|
|
157
173
|
selected = saved.get(session.environment) if isinstance(saved, dict) else None
|
|
158
174
|
if not selected:
|
|
159
|
-
raise CLIError(
|
|
175
|
+
raise CLIError(
|
|
176
|
+
"Select a project with 'hookstride projects use UUID' or --project UUID."
|
|
177
|
+
)
|
|
160
178
|
return _uuid(selected)
|
|
161
179
|
|
|
162
180
|
|
|
@@ -171,23 +189,39 @@ def _token() -> str:
|
|
|
171
189
|
|
|
172
190
|
|
|
173
191
|
def _request(
|
|
174
|
-
session: Session,
|
|
175
|
-
|
|
192
|
+
session: Session,
|
|
193
|
+
path: str,
|
|
194
|
+
*,
|
|
195
|
+
authenticate: bool = True,
|
|
196
|
+
params: dict[str, Any] | None = None,
|
|
197
|
+
method: str = "GET",
|
|
198
|
+
json_body: dict[str, Any] | None = None,
|
|
176
199
|
) -> Any:
|
|
200
|
+
if method not in {"GET", "POST", "PATCH"}:
|
|
201
|
+
raise CLIError("Unsupported API request method.")
|
|
177
202
|
headers = {"Accept": "application/json"}
|
|
178
203
|
if authenticate:
|
|
179
204
|
headers["Authorization"] = "Bearer " + _token()
|
|
180
205
|
try:
|
|
181
206
|
with httpx.Client(
|
|
182
|
-
base_url=session.origin,
|
|
207
|
+
base_url=session.origin,
|
|
208
|
+
headers=headers,
|
|
209
|
+
timeout=15,
|
|
183
210
|
follow_redirects=False,
|
|
184
211
|
) as client:
|
|
185
|
-
|
|
212
|
+
if method == "GET":
|
|
213
|
+
response = client.get(path, params=params)
|
|
214
|
+
else:
|
|
215
|
+
response = client.request(method, path, json=json_body)
|
|
186
216
|
except (httpx.HTTPError, httpx.InvalidURL, ValueError):
|
|
187
217
|
# Never print provider errors: transport exceptions may include headers.
|
|
188
|
-
raise CLIError(
|
|
218
|
+
raise CLIError(
|
|
219
|
+
"Unable to reach the Hookstride API. Check the URL and connection."
|
|
220
|
+
) from None
|
|
189
221
|
if response.status_code == 401:
|
|
190
|
-
raise CLIError(
|
|
222
|
+
raise CLIError(
|
|
223
|
+
"Authentication rejected. Check that your control token is valid."
|
|
224
|
+
)
|
|
191
225
|
if response.status_code == 403:
|
|
192
226
|
raise CLIError("Access denied for this account or project (HTTP 403).")
|
|
193
227
|
if response.status_code == 404:
|
|
@@ -244,16 +278,26 @@ def _escaped(value: Any) -> str:
|
|
|
244
278
|
def _colored_status(value: Any) -> Text:
|
|
245
279
|
label = _safe_terminal_text(value or "unknown")
|
|
246
280
|
style = {
|
|
247
|
-
"active": "green",
|
|
248
|
-
"
|
|
249
|
-
"
|
|
281
|
+
"active": "green",
|
|
282
|
+
"delivered": "green",
|
|
283
|
+
"succeeded": "green",
|
|
284
|
+
"success": "green",
|
|
285
|
+
"failed": "red",
|
|
286
|
+
"revoked": "red",
|
|
287
|
+
"abandoned": "yellow",
|
|
288
|
+
"pending": "yellow",
|
|
289
|
+
"delivering": "cyan",
|
|
250
290
|
}.get(label.lower(), "white")
|
|
251
291
|
return Text(label.upper(), style=style)
|
|
252
292
|
|
|
253
293
|
|
|
254
294
|
def _table(
|
|
255
|
-
ctx: typer.Context,
|
|
256
|
-
|
|
295
|
+
ctx: typer.Context,
|
|
296
|
+
title: str,
|
|
297
|
+
columns: list[str],
|
|
298
|
+
rows: list[list[Any]],
|
|
299
|
+
*,
|
|
300
|
+
status_column: int | None = None,
|
|
257
301
|
) -> None:
|
|
258
302
|
"""Render Metasploit-style columns without borders or wrapped identifiers."""
|
|
259
303
|
session = _session(ctx)
|
|
@@ -278,19 +322,18 @@ def _table(
|
|
|
278
322
|
# Keep names, dates, plans and statuses readable. On narrow terminals,
|
|
279
323
|
# trim identifiers/references first instead of wrapping them across lines.
|
|
280
324
|
priority = [
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
325
|
+
(
|
|
326
|
+
100
|
|
327
|
+
if ("id" in header.lower() or "reference" in header.lower())
|
|
328
|
+
else 50 if header.lower() in {"url", "error"} else 0
|
|
329
|
+
)
|
|
284
330
|
for header in columns
|
|
285
331
|
]
|
|
286
332
|
minimums = [
|
|
287
|
-
min(width, 8 if priority[i] == 100 else 4)
|
|
288
|
-
for i, width in enumerate(widths)
|
|
333
|
+
min(width, 8 if priority[i] == 100 else 4) for i, width in enumerate(widths)
|
|
289
334
|
]
|
|
290
335
|
while sum(widths) + gap * (len(widths) - 1) > available:
|
|
291
|
-
candidates = [
|
|
292
|
-
i for i in range(len(widths)) if widths[i] > minimums[i]
|
|
293
|
-
]
|
|
336
|
+
candidates = [i for i in range(len(widths)) if widths[i] > minimums[i]]
|
|
294
337
|
if not candidates:
|
|
295
338
|
break
|
|
296
339
|
index = max(candidates, key=lambda i: (priority[i], widths[i] - minimums[i]))
|
|
@@ -312,7 +355,9 @@ def _table(
|
|
|
312
355
|
return result
|
|
313
356
|
|
|
314
357
|
session.console.print(row_text([Text(col) for col in columns]), highlight=False)
|
|
315
|
-
session.console.print(
|
|
358
|
+
session.console.print(
|
|
359
|
+
row_text([Text("-" * size) for size in widths]), highlight=False
|
|
360
|
+
)
|
|
316
361
|
for values in styled_rows:
|
|
317
362
|
session.console.print(row_text(values), highlight=False)
|
|
318
363
|
|
|
@@ -329,8 +374,13 @@ def _entries(data: Any, label: str) -> list[dict[str, Any]]:
|
|
|
329
374
|
|
|
330
375
|
|
|
331
376
|
def _print_or_table(
|
|
332
|
-
ctx: typer.Context,
|
|
333
|
-
|
|
377
|
+
ctx: typer.Context,
|
|
378
|
+
data: Any,
|
|
379
|
+
title: str,
|
|
380
|
+
columns: list[str],
|
|
381
|
+
rows: list[list[Any]],
|
|
382
|
+
*,
|
|
383
|
+
status_column: int | None = None,
|
|
334
384
|
) -> None:
|
|
335
385
|
if _session(ctx).json_output:
|
|
336
386
|
_print(ctx, data)
|
|
@@ -340,7 +390,7 @@ def _print_or_table(
|
|
|
340
390
|
|
|
341
391
|
@app.command("console")
|
|
342
392
|
def console_entry(ctx: typer.Context) -> None:
|
|
343
|
-
"""Start the interactive
|
|
393
|
+
"""Start the interactive Hookstride operator console."""
|
|
344
394
|
from .console import run_console
|
|
345
395
|
|
|
346
396
|
run_console(_session(ctx))
|
|
@@ -349,12 +399,20 @@ def console_entry(ctx: typer.Context) -> None:
|
|
|
349
399
|
@app.callback(invoke_without_command=True)
|
|
350
400
|
def root(
|
|
351
401
|
ctx: typer.Context,
|
|
352
|
-
env: str = typer.Option("
|
|
353
|
-
api_url: str | None = typer.Option(
|
|
354
|
-
|
|
355
|
-
|
|
402
|
+
env: str = typer.Option("production", "--env", help="production (default) or dev."),
|
|
403
|
+
api_url: str | None = typer.Option(
|
|
404
|
+
None, "--api-url", help="Override the API origin."
|
|
405
|
+
),
|
|
406
|
+
project: str | None = typer.Option(
|
|
407
|
+
None, "--project", help="Project UUID override."
|
|
408
|
+
),
|
|
409
|
+
json_output: bool = typer.Option(
|
|
410
|
+
False, "--json", help="Machine-readable JSON, no styling."
|
|
411
|
+
),
|
|
356
412
|
no_color: bool = typer.Option(False, "--no-color", help="Disable ANSI colors."),
|
|
357
|
-
version: bool = typer.Option(
|
|
413
|
+
version: bool = typer.Option(
|
|
414
|
+
False, "--version", is_eager=True, help="Show CLI version."
|
|
415
|
+
),
|
|
358
416
|
) -> None:
|
|
359
417
|
if version:
|
|
360
418
|
typer.echo(f"hookstride {VERSION}")
|
|
@@ -410,7 +468,9 @@ def status(ctx: typer.Context) -> None:
|
|
|
410
468
|
color = "green" if online else "red"
|
|
411
469
|
label = "Online" if online else "Offline"
|
|
412
470
|
session.console.print(
|
|
413
|
-
Panel.fit(
|
|
471
|
+
Panel.fit(
|
|
472
|
+
f"[{color}]● {label}[/{color}]", title="Hookstride", border_style=color
|
|
473
|
+
)
|
|
414
474
|
)
|
|
415
475
|
if not online:
|
|
416
476
|
raise typer.Exit(code=1)
|
|
@@ -425,12 +485,15 @@ def auth_status(ctx: typer.Context) -> None:
|
|
|
425
485
|
_print(ctx, {"authenticated": True, "email": data.get("user", {}).get("email")})
|
|
426
486
|
return
|
|
427
487
|
user = data.get("user", {})
|
|
428
|
-
_session(ctx).console.print(
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
488
|
+
_session(ctx).console.print(
|
|
489
|
+
Panel.fit(
|
|
490
|
+
f"[green]✓ Authenticated[/green]\n"
|
|
491
|
+
f"Account: {_escaped(user.get('email'))}\n"
|
|
492
|
+
f"Workspace memberships: {len(data.get('memberships', []))}",
|
|
493
|
+
title="Control API",
|
|
494
|
+
border_style="green",
|
|
495
|
+
)
|
|
496
|
+
)
|
|
434
497
|
|
|
435
498
|
|
|
436
499
|
@projects_app.command("list")
|
|
@@ -439,15 +502,27 @@ def projects_list(ctx: typer.Context) -> None:
|
|
|
439
502
|
data = _request(_session(ctx), "/control/v1/projects/")
|
|
440
503
|
items = _entries(data, "projects")
|
|
441
504
|
_print_or_table(
|
|
442
|
-
ctx,
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
505
|
+
ctx,
|
|
506
|
+
data,
|
|
507
|
+
"Projects",
|
|
508
|
+
["Name", "Workspace", "Role", "Plan", "Project ID"],
|
|
509
|
+
[
|
|
510
|
+
[
|
|
511
|
+
p.get("name"),
|
|
512
|
+
p.get("account_name"),
|
|
513
|
+
p.get("role"),
|
|
514
|
+
(p.get("subscription") or {}).get("plan_code"),
|
|
515
|
+
p.get("id"),
|
|
516
|
+
]
|
|
517
|
+
for p in items
|
|
518
|
+
],
|
|
446
519
|
)
|
|
447
520
|
|
|
448
521
|
|
|
449
522
|
@projects_app.command("use")
|
|
450
|
-
def projects_use(
|
|
523
|
+
def projects_use(
|
|
524
|
+
ctx: typer.Context, project_id: str = typer.Argument(..., help="Project UUID.")
|
|
525
|
+
) -> None:
|
|
451
526
|
"""Choose a default project for this environment (only saves its UUID)."""
|
|
452
527
|
session = _session(ctx)
|
|
453
528
|
project_id = _uuid(project_id)
|
|
@@ -466,13 +541,170 @@ def projects_use(ctx: typer.Context, project_id: str = typer.Argument(..., help=
|
|
|
466
541
|
def destinations_list(ctx: typer.Context, page: int = typer.Option(1, min=1)) -> None:
|
|
467
542
|
"""List the selected project's outgoing destinations."""
|
|
468
543
|
project = _project(ctx)
|
|
469
|
-
data = _request(
|
|
544
|
+
data = _request(
|
|
545
|
+
_session(ctx),
|
|
546
|
+
f"/control/v1/projects/{project}/destinations/",
|
|
547
|
+
params={"page": page},
|
|
548
|
+
)
|
|
470
549
|
items = _entries(data, "destinations")
|
|
471
550
|
_print_or_table(
|
|
472
|
-
ctx,
|
|
473
|
-
|
|
474
|
-
|
|
551
|
+
ctx,
|
|
552
|
+
data,
|
|
553
|
+
"Destinations",
|
|
554
|
+
["Name", "URL", "Active", "Destination ID"],
|
|
555
|
+
[
|
|
556
|
+
[
|
|
557
|
+
x.get("name"),
|
|
558
|
+
x.get("url"),
|
|
559
|
+
"yes" if x.get("is_active") else "no",
|
|
560
|
+
x.get("id"),
|
|
561
|
+
]
|
|
562
|
+
for x in items
|
|
563
|
+
],
|
|
564
|
+
)
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
def _name(value: str, label: str) -> str:
|
|
568
|
+
value = value.strip()
|
|
569
|
+
if not value or len(value) > 120:
|
|
570
|
+
raise CLIError(f"{label} must be between 1 and 120 characters.")
|
|
571
|
+
return value
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
def _webhook_url(value: str) -> str:
|
|
575
|
+
"""Basic local validation; the server also enforces public-URL SSRF policy."""
|
|
576
|
+
if len(value) > 500:
|
|
577
|
+
raise CLIError("Destination URL must not exceed 500 characters.")
|
|
578
|
+
try:
|
|
579
|
+
url = urlsplit(value)
|
|
580
|
+
port = url.port
|
|
581
|
+
hostname = url.hostname
|
|
582
|
+
except ValueError:
|
|
583
|
+
raise CLIError("Invalid destination HTTPS URL.") from None
|
|
584
|
+
if (
|
|
585
|
+
url.scheme != "https"
|
|
586
|
+
or not hostname
|
|
587
|
+
or port == 0
|
|
588
|
+
or url.username
|
|
589
|
+
or url.password
|
|
590
|
+
or url.fragment
|
|
591
|
+
or any(ch.isspace() for ch in value)
|
|
592
|
+
):
|
|
593
|
+
raise CLIError("Destination must have a valid public HTTPS URL without credentials or fragment.")
|
|
594
|
+
return value
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
def _result(ctx: typer.Context, title: str, data: Any, *, secret: str | None = None) -> None:
|
|
598
|
+
if not isinstance(data, dict):
|
|
599
|
+
raise CLIError("Unexpected API response.")
|
|
600
|
+
if _session(ctx).json_output:
|
|
601
|
+
_print(ctx, data)
|
|
602
|
+
return
|
|
603
|
+
session = _session(ctx)
|
|
604
|
+
session.console.print(f"[green]✓[/green] {title}")
|
|
605
|
+
for key in ("id", "name", "slug", "url", "is_active", "account_name"):
|
|
606
|
+
if key in data:
|
|
607
|
+
session.console.print(f" {key.replace('_', ' ').title()}: {_escaped(data[key])}")
|
|
608
|
+
if secret is not None:
|
|
609
|
+
# Shown once and never saved to the CLI config or command history.
|
|
610
|
+
session.console.print("[yellow]Signing secret (save this now; it cannot be retrieved later):[/yellow]")
|
|
611
|
+
session.console.print(_plain(secret), highlight=False)
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
@projects_app.command("create")
|
|
615
|
+
def projects_create(
|
|
616
|
+
ctx: typer.Context,
|
|
617
|
+
name: str = typer.Option(..., "--name", help="New project name."),
|
|
618
|
+
account: str = typer.Option(..., "--account", help="Workspace account UUID from projects list."),
|
|
619
|
+
slug: str | None = typer.Option(None, "--slug", help="Optional project slug."),
|
|
620
|
+
) -> None:
|
|
621
|
+
"""Create a project in a workspace where you are an admin or owner."""
|
|
622
|
+
payload = {"account_id": _uuid(account), "name": _name(name, "Project name")}
|
|
623
|
+
if slug is not None:
|
|
624
|
+
if not slug.strip():
|
|
625
|
+
raise CLIError("Project slug cannot be blank.")
|
|
626
|
+
payload["slug"] = slug.strip()
|
|
627
|
+
data = _request(_session(ctx), "/control/v1/projects/", method="POST", json_body=payload)
|
|
628
|
+
_result(ctx, "Project created", data)
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
@projects_app.command("update")
|
|
632
|
+
def projects_update(
|
|
633
|
+
ctx: typer.Context,
|
|
634
|
+
project_id: str = typer.Argument(..., help="Project UUID."),
|
|
635
|
+
name: str | None = typer.Option(None, "--name", help="New project name."),
|
|
636
|
+
slug: str | None = typer.Option(None, "--slug", help="New project slug."),
|
|
637
|
+
) -> None:
|
|
638
|
+
"""Rename a project or update its slug (admin/owner only)."""
|
|
639
|
+
changes: dict[str, Any] = {}
|
|
640
|
+
if name is not None:
|
|
641
|
+
changes["name"] = _name(name, "Project name")
|
|
642
|
+
if slug is not None:
|
|
643
|
+
if not slug.strip():
|
|
644
|
+
raise CLIError("Project slug cannot be blank.")
|
|
645
|
+
changes["slug"] = slug.strip()
|
|
646
|
+
if not changes:
|
|
647
|
+
raise CLIError("Specify --name and/or --slug.")
|
|
648
|
+
project_id = _uuid(project_id)
|
|
649
|
+
data = _request(
|
|
650
|
+
_session(ctx), f"/control/v1/projects/{project_id}/",
|
|
651
|
+
method="PATCH", json_body=changes,
|
|
652
|
+
)
|
|
653
|
+
_result(ctx, "Project updated", data)
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
@destinations_app.command("create")
|
|
657
|
+
def destinations_create(
|
|
658
|
+
ctx: typer.Context,
|
|
659
|
+
name: str = typer.Option(..., "--name", help="Destination name."),
|
|
660
|
+
url: str = typer.Option(..., "--url", help="Public HTTPS webhook receiver."),
|
|
661
|
+
) -> None:
|
|
662
|
+
"""Create a destination and display its signing secret exactly once."""
|
|
663
|
+
project = _project(ctx)
|
|
664
|
+
data = _request(
|
|
665
|
+
_session(ctx), f"/control/v1/projects/{project}/destinations/",
|
|
666
|
+
method="POST", json_body={"name": _name(name, "Destination name"), "url": _webhook_url(url)},
|
|
667
|
+
)
|
|
668
|
+
if not isinstance(data, dict) or not isinstance(data.get("destination"), dict):
|
|
669
|
+
raise CLIError("Unexpected destination creation response.")
|
|
670
|
+
secret = data.get("signing_secret")
|
|
671
|
+
if not isinstance(secret, str) or not secret:
|
|
672
|
+
raise CLIError("Destination created but the signing secret was not returned. Rotate it in the dashboard.")
|
|
673
|
+
if _session(ctx).json_output:
|
|
674
|
+
_print(ctx, data)
|
|
675
|
+
else:
|
|
676
|
+
_result(ctx, "Destination created", data["destination"], secret=secret)
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
@destinations_app.command("update")
|
|
680
|
+
def destinations_update(
|
|
681
|
+
ctx: typer.Context,
|
|
682
|
+
destination_id: str = typer.Argument(..., help="Destination UUID."),
|
|
683
|
+
name: str | None = typer.Option(None, "--name", help="New destination name."),
|
|
684
|
+
url: str | None = typer.Option(None, "--url", help="New public HTTPS receiver."),
|
|
685
|
+
pause: bool = typer.Option(False, "--pause", help="Pause delivery to this destination."),
|
|
686
|
+
resume: bool = typer.Option(False, "--resume", help="Resume delivery to this destination."),
|
|
687
|
+
) -> None:
|
|
688
|
+
"""Update a destination in the selected project (developer role or above)."""
|
|
689
|
+
if pause and resume:
|
|
690
|
+
raise CLIError("Choose --pause or --resume, not both.")
|
|
691
|
+
changes: dict[str, Any] = {}
|
|
692
|
+
if name is not None:
|
|
693
|
+
changes["name"] = _name(name, "Destination name")
|
|
694
|
+
if url is not None:
|
|
695
|
+
changes["url"] = _webhook_url(url)
|
|
696
|
+
if pause or resume:
|
|
697
|
+
changes["is_active"] = bool(resume)
|
|
698
|
+
if not changes:
|
|
699
|
+
raise CLIError("Specify --name, --url, --pause, or --resume.")
|
|
700
|
+
destination_id = _uuid(destination_id)
|
|
701
|
+
project = _project(ctx)
|
|
702
|
+
data = _request(
|
|
703
|
+
_session(ctx),
|
|
704
|
+
f"/control/v1/projects/{project}/destinations/{destination_id}/",
|
|
705
|
+
method="PATCH", json_body=changes,
|
|
475
706
|
)
|
|
707
|
+
_result(ctx, "Destination updated", data)
|
|
476
708
|
|
|
477
709
|
|
|
478
710
|
@keys_app.command("list")
|
|
@@ -482,12 +714,20 @@ def keys_list(ctx: typer.Context) -> None:
|
|
|
482
714
|
data = _request(_session(ctx), f"/control/v1/projects/{project}/api-keys/")
|
|
483
715
|
items = _entries(data, "API keys")
|
|
484
716
|
_print_or_table(
|
|
485
|
-
ctx,
|
|
717
|
+
ctx,
|
|
718
|
+
data,
|
|
719
|
+
"API keys",
|
|
486
720
|
["Name", "Masked key", "Enabled", "Expires", "Key ID"],
|
|
487
|
-
[
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
721
|
+
[
|
|
722
|
+
[
|
|
723
|
+
key.get("name"),
|
|
724
|
+
key.get("masked_key"),
|
|
725
|
+
"yes" if key.get("is_active") else "no",
|
|
726
|
+
_date(key.get("expires_at")),
|
|
727
|
+
key.get("id"),
|
|
728
|
+
]
|
|
729
|
+
for key in items
|
|
730
|
+
],
|
|
491
731
|
)
|
|
492
732
|
|
|
493
733
|
|
|
@@ -495,9 +735,15 @@ def keys_list(ctx: typer.Context) -> None:
|
|
|
495
735
|
def events_list(
|
|
496
736
|
ctx: typer.Context,
|
|
497
737
|
page: int = typer.Option(1, min=1),
|
|
498
|
-
status_filter: str | None = typer.Option(
|
|
499
|
-
|
|
500
|
-
|
|
738
|
+
status_filter: str | None = typer.Option(
|
|
739
|
+
None, "--status", help="delivered, failed, pending..."
|
|
740
|
+
),
|
|
741
|
+
origin: str | None = typer.Option(
|
|
742
|
+
None, "--origin", help="api, incoming or replay."
|
|
743
|
+
),
|
|
744
|
+
search: str | None = typer.Option(
|
|
745
|
+
None, "--search", help="Event ID, type or destination."
|
|
746
|
+
),
|
|
501
747
|
) -> None:
|
|
502
748
|
"""List recent delivery activity with optional filters."""
|
|
503
749
|
project = _project(ctx)
|
|
@@ -508,12 +754,26 @@ def events_list(
|
|
|
508
754
|
params["origin"] = origin
|
|
509
755
|
if search:
|
|
510
756
|
params["q"] = search
|
|
511
|
-
data = _request(
|
|
757
|
+
data = _request(
|
|
758
|
+
_session(ctx), f"/control/v1/projects/{project}/events/", params=params
|
|
759
|
+
)
|
|
512
760
|
items = _entries(data, "events")
|
|
513
761
|
_print_or_table(
|
|
514
|
-
ctx,
|
|
515
|
-
|
|
516
|
-
|
|
762
|
+
ctx,
|
|
763
|
+
data,
|
|
764
|
+
"Activity",
|
|
765
|
+
["Created", "Event", "Destination", "Status", "Attempts", "Event ID"],
|
|
766
|
+
[
|
|
767
|
+
[
|
|
768
|
+
_date(x.get("created_at")),
|
|
769
|
+
x.get("event_type"),
|
|
770
|
+
x.get("destination_name"),
|
|
771
|
+
x.get("status"),
|
|
772
|
+
x.get("attempt_count"),
|
|
773
|
+
x.get("id"),
|
|
774
|
+
]
|
|
775
|
+
for x in items
|
|
776
|
+
],
|
|
517
777
|
status_column=3,
|
|
518
778
|
)
|
|
519
779
|
|
|
@@ -522,22 +782,37 @@ def events_list(
|
|
|
522
782
|
def events_show(ctx: typer.Context, event_id: str = typer.Argument(...)) -> None:
|
|
523
783
|
"""Inspect an event and its delivery attempts (redacted by the API)."""
|
|
524
784
|
project = _project(ctx)
|
|
525
|
-
data = _request(
|
|
785
|
+
data = _request(
|
|
786
|
+
_session(ctx), f"/control/v1/projects/{project}/events/{_uuid(event_id)}/"
|
|
787
|
+
)
|
|
526
788
|
if _session(ctx).json_output:
|
|
527
789
|
_print(ctx, data)
|
|
528
790
|
return
|
|
529
791
|
session = _session(ctx)
|
|
530
|
-
session.console.print(
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
792
|
+
session.console.print(
|
|
793
|
+
Panel.fit(
|
|
794
|
+
f"[bold]{_escaped(data.get('event_type'))}[/bold]\n"
|
|
795
|
+
f"Status: {_escaped(str(_colored_status(data.get('status'))))}\n"
|
|
796
|
+
f"Destination: {_escaped(data.get('destination_name'))}\n"
|
|
797
|
+
f"Event ID: {_escaped(data.get('id'))}",
|
|
798
|
+
title="Delivery",
|
|
799
|
+
border_style="cyan",
|
|
800
|
+
)
|
|
801
|
+
)
|
|
537
802
|
_table(
|
|
538
|
-
ctx,
|
|
539
|
-
|
|
540
|
-
|
|
803
|
+
ctx,
|
|
804
|
+
"Delivery attempts",
|
|
805
|
+
["Attempt", "HTTP", "Duration (ms)", "Time", "Error"],
|
|
806
|
+
[
|
|
807
|
+
[
|
|
808
|
+
x.get("attempt_number"),
|
|
809
|
+
x.get("status_code"),
|
|
810
|
+
x.get("duration_ms"),
|
|
811
|
+
_date(x.get("created_at")),
|
|
812
|
+
x.get("error"),
|
|
813
|
+
]
|
|
814
|
+
for x in data.get("attempts", [])
|
|
815
|
+
],
|
|
541
816
|
)
|
|
542
817
|
|
|
543
818
|
|
|
@@ -550,14 +825,17 @@ def billing_status(ctx: typer.Context) -> None:
|
|
|
550
825
|
_print(ctx, data)
|
|
551
826
|
return
|
|
552
827
|
plan = data.get("subscription") or {}
|
|
553
|
-
_session(ctx).console.print(
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
828
|
+
_session(ctx).console.print(
|
|
829
|
+
Panel.fit(
|
|
830
|
+
f"Plan: [bold]{_escaped(plan.get('plan_code'))}[/bold]\n"
|
|
831
|
+
f"Status: {_escaped(str(_colored_status(plan.get('status'))))}\n"
|
|
832
|
+
f"Flex credits: {_escaped(plan.get('flex_credits'))}\n"
|
|
833
|
+
f"Current period ends: {_escaped(_date(plan.get('current_period_end')))}\n"
|
|
834
|
+
f"Payment attempts: {len(data.get('records', []))}",
|
|
835
|
+
title="Project Billing",
|
|
836
|
+
border_style="cyan",
|
|
837
|
+
)
|
|
838
|
+
)
|
|
561
839
|
|
|
562
840
|
|
|
563
841
|
@billing_app.command("history")
|
|
@@ -567,11 +845,20 @@ def billing_history(ctx: typer.Context) -> None:
|
|
|
567
845
|
data = _request(_session(ctx), f"/control/v1/projects/{project}/billing/")
|
|
568
846
|
records = data.get("records", [])
|
|
569
847
|
_print_or_table(
|
|
570
|
-
ctx,
|
|
848
|
+
ctx,
|
|
849
|
+
records,
|
|
850
|
+
"Payment history",
|
|
571
851
|
["Date", "Plan", "Amount", "Status", "Reference"],
|
|
572
|
-
[
|
|
573
|
-
|
|
574
|
-
|
|
852
|
+
[
|
|
853
|
+
[
|
|
854
|
+
_date(r.get("created_at")),
|
|
855
|
+
r.get("plan_code"),
|
|
856
|
+
f"{r.get('currency', '')} {int(r.get('amount_minor', 0)) / 100:.2f}",
|
|
857
|
+
r.get("status"),
|
|
858
|
+
r.get("reference"),
|
|
859
|
+
]
|
|
860
|
+
for r in records
|
|
861
|
+
],
|
|
575
862
|
status_column=3,
|
|
576
863
|
)
|
|
577
864
|
|
|
@@ -583,9 +870,20 @@ def incoming_sources(ctx: typer.Context) -> None:
|
|
|
583
870
|
data = _request(_session(ctx), f"/control/v1/projects/{project}/incoming/sources/")
|
|
584
871
|
items = data.get("sources", [])
|
|
585
872
|
_print_or_table(
|
|
586
|
-
ctx,
|
|
587
|
-
|
|
588
|
-
|
|
873
|
+
ctx,
|
|
874
|
+
data,
|
|
875
|
+
"Incoming sources",
|
|
876
|
+
["Name", "Provider", "Routing", "Active", "Source ID"],
|
|
877
|
+
[
|
|
878
|
+
[
|
|
879
|
+
s.get("name"),
|
|
880
|
+
s.get("provider"),
|
|
881
|
+
s.get("routing"),
|
|
882
|
+
"yes" if s.get("is_active") else "no",
|
|
883
|
+
s.get("id"),
|
|
884
|
+
]
|
|
885
|
+
for s in items
|
|
886
|
+
],
|
|
589
887
|
)
|
|
590
888
|
|
|
591
889
|
|
|
@@ -596,11 +894,20 @@ def incoming_routes(ctx: typer.Context) -> None:
|
|
|
596
894
|
data = _request(_session(ctx), f"/control/v1/projects/{project}/incoming/routes/")
|
|
597
895
|
routes = data.get("routes", [])
|
|
598
896
|
_print_or_table(
|
|
599
|
-
ctx,
|
|
897
|
+
ctx,
|
|
898
|
+
data,
|
|
899
|
+
"Incoming routes",
|
|
600
900
|
["Source", "Destination", "Pattern", "Active", "Route ID"],
|
|
601
|
-
[
|
|
602
|
-
|
|
603
|
-
|
|
901
|
+
[
|
|
902
|
+
[
|
|
903
|
+
route.get("source"),
|
|
904
|
+
route.get("endpoint"),
|
|
905
|
+
route.get("event_pattern"),
|
|
906
|
+
"yes" if route.get("is_active") else "no",
|
|
907
|
+
route.get("id"),
|
|
908
|
+
]
|
|
909
|
+
for route in routes
|
|
910
|
+
],
|
|
604
911
|
)
|
|
605
912
|
|
|
606
913
|
|
|
@@ -611,10 +918,19 @@ def incoming_bindings(ctx: typer.Context) -> None:
|
|
|
611
918
|
data = _request(_session(ctx), f"/control/v1/projects/{project}/incoming/bindings/")
|
|
612
919
|
bindings = data.get("bindings", [])
|
|
613
920
|
_print_or_table(
|
|
614
|
-
ctx,
|
|
921
|
+
ctx,
|
|
922
|
+
data,
|
|
923
|
+
"Incoming bindings",
|
|
615
924
|
["Reference", "Source", "Destination", "Binding ID"],
|
|
616
|
-
[
|
|
617
|
-
|
|
925
|
+
[
|
|
926
|
+
[
|
|
927
|
+
item.get("reference"),
|
|
928
|
+
item.get("source"),
|
|
929
|
+
item.get("endpoint"),
|
|
930
|
+
item.get("id"),
|
|
931
|
+
]
|
|
932
|
+
for item in bindings
|
|
933
|
+
],
|
|
618
934
|
)
|
|
619
935
|
|
|
620
936
|
|
|
@@ -627,11 +943,20 @@ def incoming_registration_keys(ctx: typer.Context) -> None:
|
|
|
627
943
|
)
|
|
628
944
|
keys = data.get("keys", [])
|
|
629
945
|
_print_or_table(
|
|
630
|
-
ctx,
|
|
946
|
+
ctx,
|
|
947
|
+
data,
|
|
948
|
+
"Registration keys",
|
|
631
949
|
["Name", "Masked key", "Active", "Expiry", "Key ID"],
|
|
632
|
-
[
|
|
633
|
-
|
|
634
|
-
|
|
950
|
+
[
|
|
951
|
+
[
|
|
952
|
+
item.get("name"),
|
|
953
|
+
item.get("masked_key"),
|
|
954
|
+
"yes" if item.get("is_active") else "no",
|
|
955
|
+
_date(item.get("expires_at")),
|
|
956
|
+
item.get("id"),
|
|
957
|
+
]
|
|
958
|
+
for item in keys
|
|
959
|
+
],
|
|
635
960
|
)
|
|
636
961
|
|
|
637
962
|
|
|
@@ -645,9 +970,18 @@ def delivery_stats(ctx: typer.Context) -> None:
|
|
|
645
970
|
return
|
|
646
971
|
counts = data.get("events", {})
|
|
647
972
|
_table(
|
|
648
|
-
ctx,
|
|
649
|
-
|
|
650
|
-
|
|
973
|
+
ctx,
|
|
974
|
+
"Delivery overview",
|
|
975
|
+
["Total", "Delivered", "Failed", "Pending", "Success"],
|
|
976
|
+
[
|
|
977
|
+
[
|
|
978
|
+
counts.get("total"),
|
|
979
|
+
counts.get("delivered"),
|
|
980
|
+
counts.get("failed"),
|
|
981
|
+
counts.get("pending"),
|
|
982
|
+
f"{counts.get('success_rate', 0)}%",
|
|
983
|
+
]
|
|
984
|
+
],
|
|
651
985
|
)
|
|
652
986
|
|
|
653
987
|
|
|
@@ -656,18 +990,31 @@ def config_show(ctx: typer.Context) -> None:
|
|
|
656
990
|
"""Print the active API/profile settings, never the token value."""
|
|
657
991
|
session = _session(ctx)
|
|
658
992
|
saved = _read_config().get("projects", {})
|
|
659
|
-
selected = session.project or (
|
|
993
|
+
selected = session.project or (
|
|
994
|
+
saved.get(session.environment) if isinstance(saved, dict) else None
|
|
995
|
+
)
|
|
660
996
|
data = {
|
|
661
997
|
"environment": session.environment,
|
|
662
998
|
"api_url": session.origin,
|
|
663
999
|
"project": selected,
|
|
664
|
-
"token_configured": bool(
|
|
665
|
-
|
|
1000
|
+
"token_configured": bool(
|
|
1001
|
+
os.environ.get("HOOKSTRIDE_CONTROL_TOKEN", "").startswith("whrctl_")
|
|
1002
|
+
),
|
|
1003
|
+
"token_source": (
|
|
1004
|
+
"environment"
|
|
1005
|
+
if os.environ.get("HOOKSTRIDE_CONTROL_TOKEN", "").startswith("whrctl_")
|
|
1006
|
+
else None
|
|
1007
|
+
),
|
|
666
1008
|
}
|
|
667
1009
|
if session.json_output:
|
|
668
1010
|
_print(ctx, data)
|
|
669
1011
|
else:
|
|
670
|
-
_table(
|
|
1012
|
+
_table(
|
|
1013
|
+
ctx,
|
|
1014
|
+
"Configuration",
|
|
1015
|
+
["Setting", "Value"],
|
|
1016
|
+
[[k, v] for k, v in data.items()],
|
|
1017
|
+
)
|
|
671
1018
|
|
|
672
1019
|
|
|
673
1020
|
def main() -> None:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: hookstride-cli
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Manage Hookstride projects and destinations, inspect webhook activity and billing.
|
|
5
5
|
License: Proprietary
|
|
6
6
|
Requires-Python: >=3.11
|
|
7
7
|
Requires-Dist: click<9,>=8.1
|
|
@@ -13,9 +13,9 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
|
|
14
14
|
# Hookstride CLI
|
|
15
15
|
|
|
16
|
-
Hookstride CLI
|
|
16
|
+
Hookstride CLI lets you manage projects and webhook destinations, inspect delivery activity, and view billing records. It includes an interactive console with the same selected-project commands.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Version 0.3.0 adds project creation and updates, plus destination creation, updates, and pausing/resuming. Billing and credential changes, delivery replay, and destructive operations remain unavailable.
|
|
19
19
|
|
|
20
20
|
## Installation
|
|
21
21
|
|
|
@@ -65,8 +65,14 @@ hookstride status
|
|
|
65
65
|
hookstride auth status
|
|
66
66
|
hookstride projects list
|
|
67
67
|
hookstride projects use PROJECT_UUID
|
|
68
|
+
hookstride projects create --account ACCOUNT_UUID --name "Staging" --slug staging
|
|
69
|
+
hookstride projects update PROJECT_UUID --name "Production EU"
|
|
68
70
|
|
|
69
71
|
hookstride destinations list
|
|
72
|
+
hookstride destinations create --name "Webhook receiver" --url "https://app.example.com/webhooks/hookstride"
|
|
73
|
+
hookstride destinations update DESTINATION_UUID --url "https://api.example.com/webhooks/hookstride"
|
|
74
|
+
hookstride destinations update DESTINATION_UUID --pause
|
|
75
|
+
hookstride destinations update DESTINATION_UUID --resume
|
|
70
76
|
hookstride keys list
|
|
71
77
|
hookstride events list --status failed
|
|
72
78
|
hookstride events show EVENT_UUID
|
|
@@ -82,7 +88,7 @@ hookstride billing history
|
|
|
82
88
|
hookstride config show
|
|
83
89
|
```
|
|
84
90
|
|
|
85
|
-
Replace
|
|
91
|
+
Replace the example UUIDs with identifiers from your account. Find your workspace's `account_id` with `hookstride --json projects list`; that ID is required for project creation. Project creation and renaming require an admin/owner role. Destination changes require developer access or higher.
|
|
86
92
|
|
|
87
93
|
Commands that operate on a project use the selected project. You can override the selection for an individual command:
|
|
88
94
|
|
|
@@ -96,7 +102,7 @@ hookstride --project PROJECT_UUID events list
|
|
|
96
102
|
hookstride console
|
|
97
103
|
```
|
|
98
104
|
|
|
99
|
-
Use `help` to view commands, Tab for completion, and `exit` or Ctrl+D to leave. The console also supports `show projects`, `show events`, `show destinations`, `use PROJECT_UUID`, `back`, and `set env dev|production`.
|
|
105
|
+
Use `help` to view commands, Tab for completion, and `exit` or Ctrl+D to leave. The console also supports `show projects`, `show events`, `show destinations`, `use PROJECT_UUID`, `back`, and `set env dev|production`. The same `projects create/update` and `destinations create/update` commands work inside the console. Commands with customer-provided names and URLs are not saved to console history.
|
|
100
106
|
|
|
101
107
|
### JSON output
|
|
102
108
|
|
|
@@ -108,24 +114,23 @@ hookstride --project PROJECT_UUID --json events list --status failed
|
|
|
108
114
|
hookstride --env production --json billing history
|
|
109
115
|
```
|
|
110
116
|
|
|
111
|
-
Errors go to standard error; unsuccessful requests return a nonzero exit code.
|
|
117
|
+
Errors go to standard error; unsuccessful requests return a nonzero exit code. When creating a destination, the server returns a signing secret **once**. Save it securely immediately. Both terminal output and `--json` deliberately include that one-time secret, so avoid piping creation output into logs or public CI artifacts.
|
|
112
118
|
|
|
113
119
|
## Environments and local settings
|
|
114
120
|
|
|
115
|
-
The CLI connects to the
|
|
121
|
+
The CLI connects to the production API by default: `https://api.hookstride.com`.
|
|
122
|
+
A new release must be published to PyPI before existing installations receive this change.
|
|
116
123
|
|
|
117
|
-
To
|
|
124
|
+
To inspect the development API explicitly, select it:
|
|
118
125
|
|
|
119
126
|
```bash
|
|
120
|
-
hookstride --env
|
|
127
|
+
hookstride --env dev console
|
|
121
128
|
```
|
|
122
129
|
|
|
123
|
-
|
|
130
|
+
Development requests use `https://api-dev.hookstride.com`. Use a Control API token issued for the selected environment. A custom HTTPS API origin can be supplied with `--api-url`.
|
|
124
131
|
|
|
125
132
|
Project selections are stored separately by environment in `~/.config/hookstride/settings.json`. This file contains project identifiers, **not authentication tokens**. Console tokens and command history remain in memory and are discarded at exit.
|
|
126
133
|
|
|
127
134
|
## Documentation
|
|
128
135
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Source: https://github.com/quarj0/webhook-reliability-api/tree/main/cli
|
|
136
|
+
Documentation: https://hookstride.com
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
hookstride_cli/__init__.py,sha256=nu4rJBpNjzDjU4Gx5MN1BdUiMVx6HbsoDoYnSfWzkok,55
|
|
2
|
+
hookstride_cli/console.py,sha256=kUARFRd5XkuXsJWOJ-enAfw_dY4j6ANelZX5B1vQSpM,19126
|
|
3
|
+
hookstride_cli/main.py,sha256=q_L6e_GBD78vLx_JURuMkV9V2Ao07_OW9rKH016zA0E,34582
|
|
4
|
+
hookstride_cli-0.3.0.dist-info/METADATA,sha256=iPHreSMhrsMKt27zUgU9kjFipo2wQdXcHTFQ7TZ7Vu4,5201
|
|
5
|
+
hookstride_cli-0.3.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
6
|
+
hookstride_cli-0.3.0.dist-info/entry_points.txt,sha256=E9bqvnCFVO-lYULID8x-HTp0gYnfrYprB2R8n-DKy6Q,56
|
|
7
|
+
hookstride_cli-0.3.0.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
hookstride_cli/__init__.py,sha256=vnNXZ0Ml42k2uKUHqSZoDf9dPLCCIZOQrW2_eG6uwBo,55
|
|
2
|
-
hookstride_cli/console.py,sha256=uB4gqFlIwUaajYJ0Q_Mt4KOLImGEVbDFKBaDKJ2zgYU,18701
|
|
3
|
-
hookstride_cli/main.py,sha256=bQewSKXgBEyz1wq5CyBaVwUY6ZdRPhRCEJhW4ecDZDc,26191
|
|
4
|
-
hookstride_cli-0.2.1.dist-info/METADATA,sha256=nu-ENZXXOukHmw0yB3qBoluSwORjb1k-8OFju9LPdyU,4100
|
|
5
|
-
hookstride_cli-0.2.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
6
|
-
hookstride_cli-0.2.1.dist-info/entry_points.txt,sha256=E9bqvnCFVO-lYULID8x-HTp0gYnfrYprB2R8n-DKy6Q,56
|
|
7
|
-
hookstride_cli-0.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|