sovaria-cli 0.2.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.
- apps/cli/README.md +147 -0
- apps/cli/__init__.py +0 -0
- apps/cli/src/__init__.py +3 -0
- apps/cli/src/commands/__init__.py +1 -0
- apps/cli/src/commands/admin.py +160 -0
- apps/cli/src/commands/api.py +48 -0
- apps/cli/src/commands/audit.py +181 -0
- apps/cli/src/commands/auth_product.py +187 -0
- apps/cli/src/commands/billing.py +513 -0
- apps/cli/src/commands/chrono.py +248 -0
- apps/cli/src/commands/context.py +99 -0
- apps/cli/src/commands/data.py +272 -0
- apps/cli/src/commands/db.py +528 -0
- apps/cli/src/commands/deploy.py +1099 -0
- apps/cli/src/commands/governance.py +491 -0
- apps/cli/src/commands/iam.py +436 -0
- apps/cli/src/commands/init_cmd.py +177 -0
- apps/cli/src/commands/keys.py +120 -0
- apps/cli/src/commands/login.py +842 -0
- apps/cli/src/commands/org.py +157 -0
- apps/cli/src/commands/policy.py +317 -0
- apps/cli/src/commands/project.py +130 -0
- apps/cli/src/commands/realtime.py +364 -0
- apps/cli/src/commands/scope.py +42 -0
- apps/cli/src/commands/shell.py +415 -0
- apps/cli/src/commands/sim.py +178 -0
- apps/cli/src/commands/storage.py +405 -0
- apps/cli/src/commands/vector.py +204 -0
- apps/cli/src/main.py +169 -0
- apps/cli/src/utils/__init__.py +1 -0
- apps/cli/src/utils/api_client.py +329 -0
- apps/cli/src/utils/auth_store.py +299 -0
- apps/cli/src/utils/config.py +185 -0
- apps/cli/src/utils/display.py +62 -0
- apps/cli/src/utils/migrations.py +69 -0
- apps/cli/src/utils/project_context.py +124 -0
- apps/cli/tests/test_auth_store_profiles.py +103 -0
- apps/cli/tests/test_cli_security.py +110 -0
- apps/cli/tests/test_cli_smoke_paths.py +279 -0
- apps/cli/tests/test_config_profiles.py +55 -0
- apps/cli/tests/test_main_startup.py +29 -0
- apps/cli/tests/test_project_and_commands.py +196 -0
- sovaria_cli-0.2.0.dist-info/METADATA +170 -0
- sovaria_cli-0.2.0.dist-info/RECORD +46 -0
- sovaria_cli-0.2.0.dist-info/WHEEL +4 -0
- sovaria_cli-0.2.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""Project-scoped API key management."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from urllib.parse import quote
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
|
|
9
|
+
from apps.cli.src.utils.api_client import CLIRequestError, call_api, parse_json_arg
|
|
10
|
+
from apps.cli.src.utils.display import print_json, print_success, print_warning
|
|
11
|
+
|
|
12
|
+
app = typer.Typer(help="Project API keys (anon / service_role / custom)")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@app.command("list")
|
|
16
|
+
def list_keys(
|
|
17
|
+
profile: str | None = typer.Option(None, "--profile"),
|
|
18
|
+
org_id: str | None = typer.Option(None, "--org"),
|
|
19
|
+
project_id: str | None = typer.Option(None, "--project"),
|
|
20
|
+
env_id: str | None = typer.Option(None, "--env"),
|
|
21
|
+
) -> None:
|
|
22
|
+
"""List API keys for the current project."""
|
|
23
|
+
try:
|
|
24
|
+
result = call_api(
|
|
25
|
+
method="GET",
|
|
26
|
+
path="/api/v1/apikeys",
|
|
27
|
+
profile=profile,
|
|
28
|
+
org_id=org_id,
|
|
29
|
+
project_id=project_id,
|
|
30
|
+
env_id=env_id,
|
|
31
|
+
require_scope=True,
|
|
32
|
+
)
|
|
33
|
+
except CLIRequestError as exc:
|
|
34
|
+
typer.echo(str(exc), err=True)
|
|
35
|
+
raise typer.Exit(1) from exc
|
|
36
|
+
print_json(result)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@app.command("create")
|
|
40
|
+
def create_key(
|
|
41
|
+
name: str = typer.Option(..., "--name", help="Human-readable key name"),
|
|
42
|
+
role: str = typer.Option("service_role", "--role", help="Key role label"),
|
|
43
|
+
metadata: str | None = typer.Option(None, "--metadata", help="JSON object"),
|
|
44
|
+
profile: str | None = typer.Option(None, "--profile"),
|
|
45
|
+
org_id: str | None = typer.Option(None, "--org"),
|
|
46
|
+
project_id: str | None = typer.Option(None, "--project"),
|
|
47
|
+
env_id: str | None = typer.Option(None, "--env"),
|
|
48
|
+
) -> None:
|
|
49
|
+
"""Create a new project API key. The secret is shown once."""
|
|
50
|
+
parsed = parse_json_arg(metadata, label="--metadata") if metadata else {}
|
|
51
|
+
if parsed is not None and not isinstance(parsed, dict):
|
|
52
|
+
raise typer.BadParameter("--metadata must be a JSON object")
|
|
53
|
+
try:
|
|
54
|
+
result = call_api(
|
|
55
|
+
method="POST",
|
|
56
|
+
path="/api/v1/apikeys",
|
|
57
|
+
profile=profile,
|
|
58
|
+
org_id=org_id,
|
|
59
|
+
project_id=project_id,
|
|
60
|
+
env_id=env_id,
|
|
61
|
+
require_scope=True,
|
|
62
|
+
body={"name": name, "role": role, "metadata": parsed or {}},
|
|
63
|
+
)
|
|
64
|
+
except CLIRequestError as exc:
|
|
65
|
+
typer.echo(str(exc), err=True)
|
|
66
|
+
raise typer.Exit(1) from exc
|
|
67
|
+
print_json(result)
|
|
68
|
+
print_warning("Store the secret now — it cannot be retrieved again.")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@app.command("ensure-defaults")
|
|
72
|
+
def ensure_defaults(
|
|
73
|
+
profile: str | None = typer.Option(None, "--profile"),
|
|
74
|
+
org_id: str | None = typer.Option(None, "--org"),
|
|
75
|
+
project_id: str | None = typer.Option(None, "--project"),
|
|
76
|
+
env_id: str | None = typer.Option(None, "--env"),
|
|
77
|
+
) -> None:
|
|
78
|
+
"""Bootstrap default anon + service_role keys if missing."""
|
|
79
|
+
try:
|
|
80
|
+
result = call_api(
|
|
81
|
+
method="POST",
|
|
82
|
+
path="/api/v1/apikeys/ensure-defaults",
|
|
83
|
+
profile=profile,
|
|
84
|
+
org_id=org_id,
|
|
85
|
+
project_id=project_id,
|
|
86
|
+
env_id=env_id,
|
|
87
|
+
require_scope=True,
|
|
88
|
+
body={},
|
|
89
|
+
)
|
|
90
|
+
except CLIRequestError as exc:
|
|
91
|
+
typer.echo(str(exc), err=True)
|
|
92
|
+
raise typer.Exit(1) from exc
|
|
93
|
+
print_json(result)
|
|
94
|
+
print_success("Default API keys ensured.")
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@app.command("revoke")
|
|
98
|
+
def revoke_key(
|
|
99
|
+
key_id: str = typer.Argument(..., help="API key ID"),
|
|
100
|
+
profile: str | None = typer.Option(None, "--profile"),
|
|
101
|
+
org_id: str | None = typer.Option(None, "--org"),
|
|
102
|
+
project_id: str | None = typer.Option(None, "--project"),
|
|
103
|
+
env_id: str | None = typer.Option(None, "--env"),
|
|
104
|
+
) -> None:
|
|
105
|
+
"""Revoke an API key."""
|
|
106
|
+
try:
|
|
107
|
+
result = call_api(
|
|
108
|
+
method="DELETE",
|
|
109
|
+
path=f"/api/v1/apikeys/{quote(key_id, safe='')}",
|
|
110
|
+
profile=profile,
|
|
111
|
+
org_id=org_id,
|
|
112
|
+
project_id=project_id,
|
|
113
|
+
env_id=env_id,
|
|
114
|
+
require_scope=True,
|
|
115
|
+
)
|
|
116
|
+
except CLIRequestError as exc:
|
|
117
|
+
typer.echo(str(exc), err=True)
|
|
118
|
+
raise typer.Exit(1) from exc
|
|
119
|
+
print_json(result)
|
|
120
|
+
print_success(f"Revoked key {key_id}")
|