developer-platform-cli 0.2.0__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.
- {developer_platform_cli-0.2.0.dist-info → developer_platform_cli-0.3.0.dist-info}/METADATA +2 -2
- developer_platform_cli-0.3.0.dist-info/RECORD +16 -0
- platform_cli/__init__.py +1 -1
- platform_cli/__main__.py +28 -0
- platform_cli/api_contract.json +3467 -965
- platform_cli/client.py +4 -0
- platform_cli/commands.py +15 -6
- platform_cli/registry.py +51 -1
- platform_cli/tunnel.py +78 -0
- developer_platform_cli-0.2.0.dist-info/RECORD +0 -15
- {developer_platform_cli-0.2.0.dist-info → developer_platform_cli-0.3.0.dist-info}/WHEEL +0 -0
- {developer_platform_cli-0.2.0.dist-info → developer_platform_cli-0.3.0.dist-info}/entry_points.txt +0 -0
platform_cli/client.py
CHANGED
|
@@ -134,6 +134,10 @@ class PlatformClient:
|
|
|
134
134
|
if not path.startswith("/") or path.startswith("//") or parsed.scheme or parsed.netloc or "\\" in path or parsed.fragment or parsed.query:
|
|
135
135
|
raise ApiError(503, "The platform returned an unsafe API path.")
|
|
136
136
|
attempts = 3 if method == "GET" else 1
|
|
137
|
+
if (method == "POST" and len(parsed.path.split("/")) == 5
|
|
138
|
+
and parsed.path.startswith("/projects/") and parsed.path.endswith("/ai/runs")):
|
|
139
|
+
# Synchronous AI investigations have a 90-second server budget.
|
|
140
|
+
kwargs["timeout"] = httpx.Timeout(120.0, connect=5.0)
|
|
137
141
|
for attempt in range(attempts):
|
|
138
142
|
started = time.monotonic()
|
|
139
143
|
try:
|
platform_cli/commands.py
CHANGED
|
@@ -25,7 +25,7 @@ from .registry import COMMANDS, CommandSpec
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
SENSITIVE_KEYS = {"client_secret", "clientsecret", "access_token", "accesstoken", "refresh_token",
|
|
28
|
-
"refreshtoken", "id_token", "idtoken", "password", "private_key", "privatekey", "authorization"}
|
|
28
|
+
"refreshtoken", "id_token", "idtoken", "password", "private_key", "privatekey", "authorization", "pgpassword", "aws_secret_access_key", "opensearch_password", "qdrant_api_key", "neo4j_password"}
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
class AccessOperationFailed(RuntimeError):
|
|
@@ -308,9 +308,14 @@ def execute(spec: CommandSpec, state, values: dict):
|
|
|
308
308
|
path = _path(spec, values)
|
|
309
309
|
if spec.command.startswith("secrets ") and values.get("secret", "").startswith("ACCESS_"):
|
|
310
310
|
raise ConfigurationError("Managed service credentials must be changed with access services commands.")
|
|
311
|
-
if spec.
|
|
311
|
+
store_target = ("resource_id" if spec.command in {"stores retire", "stores purge"}
|
|
312
|
+
else "grant_id" if spec.command == "stores grants revoke" else None)
|
|
313
|
+
if store_target and values.get("confirm_" + store_target) != values[store_target]:
|
|
314
|
+
raise ConfigurationError("Confirm the exact " + store_target.replace("_", " ") +
|
|
315
|
+
" with --confirm-" + store_target.replace("_", "-") + ".")
|
|
316
|
+
if spec.destructive and not store_target and not values.get("confirm_project"):
|
|
312
317
|
raise ConfigurationError("Confirm the exact project/scope with --confirm-project NAME.")
|
|
313
|
-
if spec.destructive and values["confirm_project"] != (values.get("project") or "platform"):
|
|
318
|
+
if spec.destructive and not store_target and values["confirm_project"] != (values.get("project") or "platform"):
|
|
314
319
|
raise ConfigurationError("The confirmation scope does not match this request.")
|
|
315
320
|
body = _body(spec, values)
|
|
316
321
|
headers = {}
|
|
@@ -378,7 +383,9 @@ def execute(spec: CommandSpec, state, values: dict):
|
|
|
378
383
|
time.monotonic, time.sleep, lambda s: typer.echo("Operation " + s.operation_id + ": " + s.state, err=True)
|
|
379
384
|
if output != "json" and not state.quiet else None)
|
|
380
385
|
result = status.model_dump()
|
|
381
|
-
if spec.credential:
|
|
386
|
+
if spec.command == "stores access credential":
|
|
387
|
+
typer.echo("Sensitive credential material: keep it in a protected secret store.", err=True)
|
|
388
|
+
elif spec.credential:
|
|
382
389
|
typer.echo("Credential material is returned once; store it in a protected secret store.", err=True)
|
|
383
390
|
emit(result, output, one_time=spec.credential)
|
|
384
391
|
if spec.command == "logs" and values.get("follow"):
|
|
@@ -406,7 +413,8 @@ def execute(spec: CommandSpec, state, values: dict):
|
|
|
406
413
|
|
|
407
414
|
def register(app: typer.Typer, spec: CommandSpec):
|
|
408
415
|
"""Expose only the options relevant to this operation, retaining domain names."""
|
|
409
|
-
positional = [name for name in ("resource_id", "credential_id", "operation_id", "request_id", "secret"
|
|
416
|
+
positional = [name for name in ("resource_id", "credential_id", "operation_id", "request_id", "secret",
|
|
417
|
+
"trace_id", "run_id", "proposal_id", "grant_id") if "{" + name + "}" in spec.path]
|
|
410
418
|
params = [inspect.Parameter("ctx", inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=typer.Context)]
|
|
411
419
|
for name in positional:
|
|
412
420
|
params.append(inspect.Parameter(name, inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
|
@@ -431,7 +439,8 @@ def register(app: typer.Typer, spec: CommandSpec):
|
|
|
431
439
|
if spec.command == "logs":
|
|
432
440
|
options.extend(("follow", "poll_interval"))
|
|
433
441
|
if spec.destructive:
|
|
434
|
-
options.append("
|
|
442
|
+
options.append("confirm_resource_id" if spec.command in {"stores retire", "stores purge"}
|
|
443
|
+
else "confirm_grant_id" if spec.command == "stores grants revoke" else "confirm_project")
|
|
435
444
|
if spec.family and spec.method != "GET":
|
|
436
445
|
options.extend(("wait", "timeout", "poll_interval"))
|
|
437
446
|
options.append("output")
|
platform_cli/registry.py
CHANGED
|
@@ -55,6 +55,16 @@ LOG_FILTERS = ("tail", "since", "component", "instance", "after", "before")
|
|
|
55
55
|
add("logs", "GET", P + "/logs", "Read or follow bounded current logs.", query=LOG_FILTERS + ("search",))
|
|
56
56
|
add("logs retained", "GET", P + "/retained-logs", "Read retained operational log envelopes.", query=LOG_FILTERS)
|
|
57
57
|
add("operations get", "GET", "/v1/operations/{operation_id}", "Inspect a deployment operation.", family="deployment")
|
|
58
|
+
add("metrics get", "GET", P + "/application-metrics", "Read bounded application HTTP metrics.", query=("component",))
|
|
59
|
+
add("traces get", "GET", P + "/traces/{trace_id}", "Read a retained project-scoped trace.")
|
|
60
|
+
add("ai policy get", "GET", P + "/ai/policy", "Read the project's AI data classification.")
|
|
61
|
+
add("ai policy replace", "PUT", P + "/ai/policy", "Set the project's AI data classification from JSON.", body="file", destructive=True)
|
|
62
|
+
add("ai runs create", "POST", P + "/ai/runs", "Start an authorized AI investigation from JSON.", body="file")
|
|
63
|
+
add("ai runs get", "GET", P + "/ai/runs/{run_id}", "Read a project-scoped AI run and its evidence.")
|
|
64
|
+
add("ai proposals create", "POST", P + "/ai/proposals", "Create a reviewable proposal from an AI run.", body="file")
|
|
65
|
+
add("ai proposals get", "GET", P + "/ai/proposals/{proposal_id}", "Read a proposal, its bound diff, and observed result.")
|
|
66
|
+
add("ai proposals approve", "POST", P + "/ai/proposals/{proposal_id}/approval", "Approve an exact diff hash from JSON.", body="file", destructive=True)
|
|
67
|
+
add("ai proposals execute", "POST", P + "/ai/proposals/{proposal_id}/execute", "Execute an approved exact diff hash from JSON.", body="file", destructive=True)
|
|
58
68
|
add("config replace", "PUT", P + "/configuration", "Replace configuration from a complete JSON document.", body="file", version="deployment", family="deployment")
|
|
59
69
|
add("restart", "POST", P + "/restart", "Restart application workloads.", family="deployment", destructive=True)
|
|
60
70
|
add("rollback", "POST", P + "/rollback", "Restore a retained deployment revision.", body="revision", fields=("revision",), family="deployment", destructive=True)
|
|
@@ -69,6 +79,10 @@ for action, method in (("set", "PUT"), ("delete", "DELETE")):
|
|
|
69
79
|
add("credentials create", "POST", P + "/deployment-credentials", "Create a CI credential; return its secret once.", body="credential", fields=("name", "expires_in_days"), credential=True)
|
|
70
80
|
add("credentials rotate", "POST", P + "/deployment-credentials/{credential_id}/rotate", "Rotate a CI credential with bounded overlap.", body="credential", fields=("expires_in_days", "overlap_hours"), credential=True)
|
|
71
81
|
add("credentials revoke", "DELETE", P + "/deployment-credentials/{credential_id}", "Revoke a CI credential.", destructive=True)
|
|
82
|
+
add("database-access grants list", "GET", P + "/database-access/grants", "List named human database grants.")
|
|
83
|
+
add("database-access grants revoke", "DELETE", P + "/database-access/grants", "Revoke a human database grant and terminate its sessions.", body="grant", fields=("issuer", "subject"), destructive=True)
|
|
84
|
+
add("database-access me", "GET", P + "/database-access/me", "Inspect your database tunnel identity.")
|
|
85
|
+
add("database-access key replace", "PUT", P + "/database-access/me/key", "Replace your SSH public key using a JSON file.", body="file")
|
|
72
86
|
|
|
73
87
|
for command, suffix, description, query, resource in (
|
|
74
88
|
("access context", "application-access-context", "Inspect access eligibility and permissions.", (), False),
|
|
@@ -134,4 +148,40 @@ for family, collection, fields in (
|
|
|
134
148
|
add("operator " + family + " revoke", "DELETE", collection + "/{credential_id}", "Revoke a test automation identity.", destructive=True)
|
|
135
149
|
add("operator test-runner-credentials rotate", "POST", "/platform/test-runner-credentials/{credential_id}/rotate", "Rotate a test runner credential.", body="credential", fields=("expires_in_days", "overlap_hours"), credential=True, destructive=True)
|
|
136
150
|
|
|
137
|
-
EXCLUSIONS = {
|
|
151
|
+
EXCLUSIONS = {
|
|
152
|
+
("GET", "/healthz"): "Service liveness probe",
|
|
153
|
+
("GET", "/readyz"): "Service readiness probe",
|
|
154
|
+
("POST", P + "/database-access/grants"): "Obsolete endpoint always returns HTTP 410",
|
|
155
|
+
("POST", P + "/database-access/me/credential"): "Obsolete endpoint always returns HTTP 410",
|
|
156
|
+
("POST", "/v1/store-access/credentials/{credential_id}/console"): "Browser-only console launch assertion",
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
# Named store resources use body versions and explicit UUID scope confirmations.
|
|
161
|
+
add("stores list", "GET", A + "/resources", "List independent named resources.")
|
|
162
|
+
add("stores create", "POST", A + "/resources", "Create a named store resource from JSON.", body="file")
|
|
163
|
+
S = "/v1/resources/{resource_id}"
|
|
164
|
+
add("stores get", "GET", S, "Inspect resource provisioning and quota enforcement.")
|
|
165
|
+
add("stores rename", "PATCH", S, "Rename a resource without changing its stable identity.", body="file")
|
|
166
|
+
add("stores quota", "PUT", S + "/quota", "Approve a capacity-checked quota change (platform admin).", body="file")
|
|
167
|
+
add("stores retire", "POST", S + "/retirement", "Revoke access and retain the named resource.", body="file", destructive=True)
|
|
168
|
+
add("stores purge-preview", "GET", S + "/purge-preview", "Preview the exact resource purge scope.")
|
|
169
|
+
add("stores purge", "POST", S + "/purge", "Purge a retired resource with exact UUID/owner/version confirmation.", body="file", destructive=True)
|
|
170
|
+
add("stores grants list", "GET", S + "/grants", "List human grants and component requests.")
|
|
171
|
+
add("stores grants create", "POST", S + "/human-grants", "Create a resource-scoped human grant.", body="file")
|
|
172
|
+
add("stores bindings list", "GET", A + "/resource-bindings", "List outgoing component bindings.")
|
|
173
|
+
add("stores bindings request", "POST", A + "/resource-bindings", "Request explicit component access.", body="file")
|
|
174
|
+
G = "/v1/resource-grants/{grant_id}"
|
|
175
|
+
add("stores grants approve", "POST", G + "/approval", "Approve or reject a cross-project request.", body="file")
|
|
176
|
+
add("stores grants mode", "PUT", G + "/mode", "Change resource-scoped permissions using the current version.", body="file")
|
|
177
|
+
add("stores grants revoke", "POST", G + "/revocation", "Revoke a grant and all credential generations.", body="file", destructive=True)
|
|
178
|
+
add("stores access me", "GET", "/v1/store-access/me", "List your explicit named-resource grants.")
|
|
179
|
+
add("stores access key", "PUT", "/v1/store-access/me/key", "Replace your Ed25519 key; end current leases.", body="file")
|
|
180
|
+
add("stores access issue", "POST", "/v1/store-access/{grant_id}/credentials", "Issue a new 24-hour credential lease.")
|
|
181
|
+
add("stores access credential", "GET", "/v1/store-access/credentials/{credential_id}", "Reveal your active scoped credential (sensitive output).", credential=True)
|
|
182
|
+
|
|
183
|
+
add("stores context", "GET", A + "/store-context", "Inspect store administration permissions and enabled providers.")
|
|
184
|
+
add("stores access leases", "GET", "/v1/store-access/{grant_id}/credentials", "List your non-secret credential lease metadata.")
|
|
185
|
+
add("ai context", "GET", P + "/ai/context", "Inspect AI permissions and current revision.")
|
|
186
|
+
add("ai runs list", "GET", P + "/ai/runs", "List project-scoped AI run history.", query=("limit", "before"))
|
|
187
|
+
add("ai proposals list", "GET", P + "/ai/proposals", "List project-scoped AI change proposals.", query=("limit", "before"))
|
platform_cli/tunnel.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""Open a local TCP forward for an active named-store credential."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import ipaddress
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import re
|
|
8
|
+
import stat
|
|
9
|
+
import subprocess
|
|
10
|
+
|
|
11
|
+
from .config import ConfigurationError
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _file(path: str, *, private: bool) -> Path:
|
|
15
|
+
try:
|
|
16
|
+
selected = Path(path).expanduser().resolve(strict=True)
|
|
17
|
+
mode = selected.stat().st_mode
|
|
18
|
+
except OSError:
|
|
19
|
+
raise ConfigurationError("The SSH identity or known-hosts file does not exist or is unreadable.") from None
|
|
20
|
+
if not stat.S_ISREG(mode):
|
|
21
|
+
raise ConfigurationError("SSH key and known-hosts paths must be regular files.")
|
|
22
|
+
if private and mode & 0o077:
|
|
23
|
+
raise ConfigurationError("The SSH identity file must be readable only by its owner.")
|
|
24
|
+
return selected
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _port(value: object) -> int:
|
|
28
|
+
if isinstance(value, bool) or not isinstance(value, int) or not 1 <= value <= 65535:
|
|
29
|
+
raise ConfigurationError("The platform returned an invalid SSH port.")
|
|
30
|
+
return value
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def ssh_command(credential: dict, identity_file: str, known_hosts: str, local_port: int) -> list[str]:
|
|
34
|
+
"""Build an SSH command using only validated server connection details."""
|
|
35
|
+
if credential.get("state") != "active":
|
|
36
|
+
raise ConfigurationError("The credential is not active; inspect it again after issuance completes.")
|
|
37
|
+
if credential.get("provider") not in {"postgresql", "s3", "qdrant", "opensearch", "neo4j"}:
|
|
38
|
+
raise ConfigurationError("The credential has an unsupported store provider.")
|
|
39
|
+
ssh = credential.get("ssh")
|
|
40
|
+
if not isinstance(ssh, dict):
|
|
41
|
+
raise ConfigurationError("No reachable SSH bastion is configured for this credential.")
|
|
42
|
+
if ssh.get("user") != "platform-db":
|
|
43
|
+
raise ConfigurationError("The platform returned an unexpected SSH user.")
|
|
44
|
+
host = ssh.get("host")
|
|
45
|
+
if not isinstance(host, str) or not host or len(host) > 253:
|
|
46
|
+
raise ConfigurationError("The platform returned an invalid SSH host.")
|
|
47
|
+
try:
|
|
48
|
+
ipaddress.ip_address(host)
|
|
49
|
+
except ValueError:
|
|
50
|
+
if not re.fullmatch(r"[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?", host):
|
|
51
|
+
raise ConfigurationError("The platform returned an invalid SSH host.") from None
|
|
52
|
+
destination = ssh.get("destination")
|
|
53
|
+
try:
|
|
54
|
+
if not isinstance(destination, str):
|
|
55
|
+
raise ValueError()
|
|
56
|
+
ipaddress.ip_address(destination)
|
|
57
|
+
except ValueError:
|
|
58
|
+
raise ConfigurationError("The platform returned an invalid relay address.") from None
|
|
59
|
+
remote_port = _port(ssh.get("destination_port"))
|
|
60
|
+
ssh_port = _port(ssh.get("port"))
|
|
61
|
+
if not isinstance(local_port, int) or isinstance(local_port, bool) or not 1 <= local_port <= 65535:
|
|
62
|
+
raise ConfigurationError("Choose a local TCP port from 1 to 65535.")
|
|
63
|
+
key = _file(identity_file, private=True)
|
|
64
|
+
hosts = _file(known_hosts, private=False)
|
|
65
|
+
destination_address = f"[{destination}]" if ":" in destination else destination
|
|
66
|
+
return ["ssh", "-F", "/dev/null", "-N", "-T", "-i", str(key), "-p", str(ssh_port),
|
|
67
|
+
"-o", "BatchMode=yes", "-o", "IdentitiesOnly=yes", "-o", "PasswordAuthentication=no",
|
|
68
|
+
"-o", "KbdInteractiveAuthentication=no", "-o", "StrictHostKeyChecking=yes",
|
|
69
|
+
"-o", "UserKnownHostsFile=" + str(hosts), "-o", "GlobalKnownHostsFile=/dev/null",
|
|
70
|
+
"-o", "ExitOnForwardFailure=yes", "-o", "ConnectTimeout=5",
|
|
71
|
+
"-L", f"127.0.0.1:{local_port}:{destination_address}:{remote_port}", "platform-db@" + host]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def run_tunnel(command: list[str]) -> int:
|
|
75
|
+
try:
|
|
76
|
+
return subprocess.run(command, check=False).returncode
|
|
77
|
+
except FileNotFoundError:
|
|
78
|
+
raise ConfigurationError("OpenSSH 'ssh' is required to open a store tunnel.") from None
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
platform_cli/__init__.py,sha256=3pnCImon2ZJc0V_dh8ESALZOalenXMwbD0ftP4lo2cM,69
|
|
2
|
-
platform_cli/__main__.py,sha256=3zCs59mHyp4lx_xTf51HuRNkHRAOoxTSIZ1AOB_WK7E,17876
|
|
3
|
-
platform_cli/api_contract.json,sha256=NUkTwF3MbFnfwInAFfu2LN3FLg67lLWgt-gAOFkpA30,148032
|
|
4
|
-
platform_cli/authentication.py,sha256=zMXky1tj2zi5WddkUtwZC0UE32BDGcAtY1VqlH40D8M,7071
|
|
5
|
-
platform_cli/client.py,sha256=c6fiK6KcAjpdS-Zorv_a4vLFRUiDM3R-8u6askEEkDM,10484
|
|
6
|
-
platform_cli/commands.py,sha256=QZYJx6cKkREe5KZSWj27y4S7fzMTypkdjgAn6r-466o,22934
|
|
7
|
-
platform_cli/config.py,sha256=5bnFRT4Z_qgQ6WWa4mODvidUuqzwsxwCKj1mMOhJOYA,3776
|
|
8
|
-
platform_cli/errors.py,sha256=jc8COhzP0KKYu93w9ZaVMLfXy5FT5bfSUvuKeOrhcZM,1188
|
|
9
|
-
platform_cli/models.py,sha256=DeUjuS0ma8dXPDHch8xnj0dQrtvq7PvOe_Bu4EIukUQ,1756
|
|
10
|
-
platform_cli/profiles.py,sha256=KMaiKFxf3NTc0bfSDa4E5kNs_Mby4BuXtBc9VG_G1Nc,6263
|
|
11
|
-
platform_cli/registry.py,sha256=jT6OK5s1_HM0VYoVGw8sgvZq9IkZG3ap9RQQcOnfkss,11464
|
|
12
|
-
developer_platform_cli-0.2.0.dist-info/METADATA,sha256=GpwyKeDsrpVkRmt9rjNTHB7_uayfkny3j1fGK07UxxU,2045
|
|
13
|
-
developer_platform_cli-0.2.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
14
|
-
developer_platform_cli-0.2.0.dist-info/entry_points.txt,sha256=M7MpiSzj86vx01JPP3zjnrykkQuxJjTnS9o5Rs0CAkI,55
|
|
15
|
-
developer_platform_cli-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
{developer_platform_cli-0.2.0.dist-info → developer_platform_cli-0.3.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|