testzeus-cli 0.0.26__tar.gz → 0.0.27__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.
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/PKG-INFO +1 -1
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/pyproject.toml +1 -1
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/agent_harness.py +51 -21
- testzeus_cli-0.0.27/testzeus_cli/commands/connected_environments.py +123 -0
- testzeus_cli-0.0.26/testzeus_cli/commands/connected_environments.py +0 -447
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/LICENSE +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/README.md +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/__init__.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/auth.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/cli.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/__init__.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/daemon.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/device_pool.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/environments.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/extensions.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/hypermind_code_blocks.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/knowledge_bases.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/notification_channels.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/tags.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_data.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_report_runs.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_report_schedules.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_run_groups.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_runs.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_suite_node_runs.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_suite_runs.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_suite_schedules.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_suites.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/tests.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/tests_ai_generator.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/tests_authoring.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/commands/user_integrations.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/config.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/utils/__init__.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/utils/auth.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/utils/client.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/utils/files.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/utils/formatters.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/utils/links.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/utils/profile.py +0 -0
- {testzeus_cli-0.0.26 → testzeus_cli-0.0.27}/testzeus_cli/utils/validators.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "testzeus-cli"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.27"
|
|
8
8
|
description = "Command-line interface for TestZeus testing platform"
|
|
9
9
|
authors = ["Shriyansh Agnihotri <shriyansh@testzeus.com>"]
|
|
10
10
|
readme = "README.md"
|
|
@@ -6,6 +6,8 @@ generate adversarial pathways, run simulations, and monitor / cancel them.
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import asyncio
|
|
9
|
+
from typing import Any, Dict
|
|
10
|
+
|
|
9
11
|
import click
|
|
10
12
|
from rich.console import Console
|
|
11
13
|
from testzeus_sdk import TestZeusClient
|
|
@@ -18,15 +20,37 @@ from testzeus_cli.utils.links import print_platform_link
|
|
|
18
20
|
console = Console()
|
|
19
21
|
|
|
20
22
|
|
|
23
|
+
def _pathway_row(data: Dict[str, Any]) -> Dict[str, Any]:
|
|
24
|
+
"""Trim a pathway record to the columns worth showing in a list.
|
|
25
|
+
|
|
26
|
+
Dumping the raw record lets the generic 6-column table fill up with noise
|
|
27
|
+
(tenant/created_by/modified_by) and hide the useful fields, so project to
|
|
28
|
+
name/risk_level/objective/status explicitly.
|
|
29
|
+
"""
|
|
30
|
+
objective = data.get("objective") or ""
|
|
31
|
+
if len(objective) > 80:
|
|
32
|
+
objective = objective[:77] + "..."
|
|
33
|
+
return {
|
|
34
|
+
"id": data.get("id"),
|
|
35
|
+
"name": data.get("name"),
|
|
36
|
+
"risk_level": data.get("risk_level"),
|
|
37
|
+
"objective": objective,
|
|
38
|
+
"status": data.get("status"),
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
21
42
|
def _client(ctx):
|
|
22
43
|
"""Build the config + client tuple used by every command."""
|
|
23
44
|
config, token, tenant_id, user_id = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
24
45
|
return TestZeusClient(**config), token, tenant_id, user_id
|
|
25
46
|
|
|
26
47
|
|
|
27
|
-
async def _auth(client, token):
|
|
48
|
+
async def _auth(client, token, tenant_id=None):
|
|
28
49
|
if token:
|
|
29
|
-
|
|
50
|
+
# Thread the profile tenant so tenant injection works even when the token
|
|
51
|
+
# has no tenant claim; otherwise create/run fails deep in the SDK with
|
|
52
|
+
# "No tenant ID available when adding tenant ID".
|
|
53
|
+
initialize_client_with_token(client, token, profile_tenant_id=tenant_id)
|
|
30
54
|
else:
|
|
31
55
|
await client.ensure_authenticated()
|
|
32
56
|
if not hasattr(client, "agent_harness"):
|
|
@@ -49,9 +73,9 @@ def list_agents(ctx, page, per_page, status, search):
|
|
|
49
73
|
"""List available agents"""
|
|
50
74
|
|
|
51
75
|
async def _run():
|
|
52
|
-
client, token,
|
|
76
|
+
client, token, tenant_id, _ = _client(ctx)
|
|
53
77
|
async with client:
|
|
54
|
-
await _auth(client, token)
|
|
78
|
+
await _auth(client, token, tenant_id)
|
|
55
79
|
return await client.agent_harness.list_agents(page=page, per_page=per_page, status=status, search=search)
|
|
56
80
|
|
|
57
81
|
try:
|
|
@@ -75,13 +99,14 @@ def list_pathways(ctx, agent_id, page, per_page):
|
|
|
75
99
|
# argument instead. The SDK builds the agent_id filter via the shared filter
|
|
76
100
|
# builder; add --filters/--sort here if the manager grows to support them.
|
|
77
101
|
async def _run():
|
|
78
|
-
client, token,
|
|
102
|
+
client, token, tenant_id, _ = _client(ctx)
|
|
79
103
|
async with client:
|
|
80
|
-
await _auth(client, token)
|
|
104
|
+
await _auth(client, token, tenant_id)
|
|
81
105
|
agent = validate_id(agent_id, "agent")
|
|
82
106
|
res = await client.agent_harness.list_pathways(agent_id=agent, page=page, per_page=per_page)
|
|
83
|
-
# get_list returns AdversaryPathways models;
|
|
84
|
-
|
|
107
|
+
# get_list returns AdversaryPathways models; project to the useful
|
|
108
|
+
# columns (name/risk/objective/status) so they aren't crowded out.
|
|
109
|
+
res["items"] = [_pathway_row(p.data) for p in res.get("items", [])]
|
|
85
110
|
return res
|
|
86
111
|
|
|
87
112
|
try:
|
|
@@ -104,9 +129,9 @@ def generate_pathways(ctx, agent_profile, prompt, name, agent_name, num, allow_d
|
|
|
104
129
|
"""Start an AI pathway-generation job for a Salesforce agent profile"""
|
|
105
130
|
|
|
106
131
|
async def _run():
|
|
107
|
-
client, token,
|
|
132
|
+
client, token, tenant_id, _ = _client(ctx)
|
|
108
133
|
async with client:
|
|
109
|
-
await _auth(client, token)
|
|
134
|
+
await _auth(client, token, tenant_id)
|
|
110
135
|
# tenant/created_by/modified_by are auto-filled by the SDK manager.
|
|
111
136
|
return await client.agent_harness.generate_pathways(
|
|
112
137
|
agent_profile=agent_profile,
|
|
@@ -140,9 +165,9 @@ def run(ctx, agent_id, pathways, name, agent_name, run_as_profile, wait, timeout
|
|
|
140
165
|
"""Run adversarial simulations for the given pathways"""
|
|
141
166
|
|
|
142
167
|
async def _run():
|
|
143
|
-
client, token,
|
|
168
|
+
client, token, tenant_id, _ = _client(ctx)
|
|
144
169
|
async with client:
|
|
145
|
-
await _auth(client, token)
|
|
170
|
+
await _auth(client, token, tenant_id)
|
|
146
171
|
agent = validate_id(agent_id, "agent")
|
|
147
172
|
# tenant/created_by/modified_by are auto-filled by the SDK manager.
|
|
148
173
|
if wait:
|
|
@@ -187,9 +212,9 @@ def status(ctx, group_id):
|
|
|
187
212
|
"""Get the status/results of a simulation run group"""
|
|
188
213
|
|
|
189
214
|
async def _run():
|
|
190
|
-
client, token,
|
|
215
|
+
client, token, tenant_id, _ = _client(ctx)
|
|
191
216
|
async with client:
|
|
192
|
-
await _auth(client, token)
|
|
217
|
+
await _auth(client, token, tenant_id)
|
|
193
218
|
return await client.agent_harness.get_status(validate_id(group_id, "group"))
|
|
194
219
|
|
|
195
220
|
try:
|
|
@@ -206,9 +231,9 @@ def cancel(ctx, group_id):
|
|
|
206
231
|
"""Cancel a running simulation group"""
|
|
207
232
|
|
|
208
233
|
async def _run():
|
|
209
|
-
client, token,
|
|
234
|
+
client, token, tenant_id, _ = _client(ctx)
|
|
210
235
|
async with client:
|
|
211
|
-
await _auth(client, token)
|
|
236
|
+
await _auth(client, token, tenant_id)
|
|
212
237
|
return await client.agent_harness.cancel(validate_id(group_id, "group"))
|
|
213
238
|
|
|
214
239
|
try:
|
|
@@ -226,14 +251,19 @@ def get_agent(ctx, agent_id):
|
|
|
226
251
|
"""Get full detail for a single agent"""
|
|
227
252
|
|
|
228
253
|
async def _run():
|
|
229
|
-
client, token,
|
|
254
|
+
client, token, tenant_id, _ = _client(ctx)
|
|
230
255
|
async with client:
|
|
231
|
-
await _auth(client, token)
|
|
256
|
+
await _auth(client, token, tenant_id)
|
|
232
257
|
return await client.agent_harness.get_agent(validate_id(agent_id, "agent"))
|
|
233
258
|
|
|
234
259
|
try:
|
|
235
260
|
print_platform_link(ctx, "agent-harness")
|
|
236
|
-
|
|
261
|
+
result = asyncio.run(_run())
|
|
262
|
+
# The gateway wraps the agent under "item"; unwrap it so the full record
|
|
263
|
+
# renders as a field table instead of collapsing to one "name (id)" line.
|
|
264
|
+
if isinstance(result, dict) and isinstance(result.get("item"), dict):
|
|
265
|
+
result = result["item"]
|
|
266
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
237
267
|
except Exception as e:
|
|
238
268
|
print_message(f"[red]Error getting agent: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
239
269
|
raise click.Abort()
|
|
@@ -246,9 +276,9 @@ def delete_pathway(ctx, pathway_id):
|
|
|
246
276
|
"""Soft-delete an adversarial pathway"""
|
|
247
277
|
|
|
248
278
|
async def _run():
|
|
249
|
-
client, token,
|
|
279
|
+
client, token, tenant_id, _ = _client(ctx)
|
|
250
280
|
async with client:
|
|
251
|
-
await _auth(client, token)
|
|
281
|
+
await _auth(client, token, tenant_id)
|
|
252
282
|
return await client.agent_harness.delete_pathway(validate_id(pathway_id, "pathway"))
|
|
253
283
|
|
|
254
284
|
try:
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Connected environment management commands for TestZeus CLI.
|
|
3
|
+
|
|
4
|
+
Scoped to read + rename only: connected environments are created and their code /
|
|
5
|
+
metadata files are managed from the web UI, so the CLI exposes just ``list``,
|
|
6
|
+
``get`` and a name-only ``update``.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import asyncio
|
|
10
|
+
import click
|
|
11
|
+
from rich.console import Console
|
|
12
|
+
from testzeus_sdk import TestZeusClient
|
|
13
|
+
from testzeus_cli.config import get_client_config
|
|
14
|
+
from testzeus_cli.utils.formatters import format_output, print_message
|
|
15
|
+
from testzeus_cli.utils.auth import initialize_client_with_token
|
|
16
|
+
from testzeus_cli.utils.validators import parse_key_value_pairs, validate_tenant_ownership
|
|
17
|
+
|
|
18
|
+
console = Console()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@click.group()
|
|
22
|
+
def connected_environments_group():
|
|
23
|
+
"""Manage connected environments in TestZeus"""
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@connected_environments_group.command(name="list")
|
|
28
|
+
@click.option("--filters", "-f", multiple=True, help="Filter results (format: key=value)")
|
|
29
|
+
@click.option("--sort", help="Sort by field")
|
|
30
|
+
@click.option("--expand", help="Expand related entities")
|
|
31
|
+
@click.pass_context
|
|
32
|
+
def list(ctx, filters, sort, expand):
|
|
33
|
+
"""List all connected environments"""
|
|
34
|
+
|
|
35
|
+
async def _run():
|
|
36
|
+
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
37
|
+
client = TestZeusClient(**config)
|
|
38
|
+
filter_dict = parse_key_value_pairs(filters) if filters else {}
|
|
39
|
+
async with client:
|
|
40
|
+
if token:
|
|
41
|
+
initialize_client_with_token(client, token)
|
|
42
|
+
else:
|
|
43
|
+
await client.ensure_authenticated()
|
|
44
|
+
result = await client.connected_environments.get_list(expand=expand, sort=sort, filters=filter_dict)
|
|
45
|
+
return result
|
|
46
|
+
|
|
47
|
+
try:
|
|
48
|
+
result = asyncio.run(_run())
|
|
49
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
50
|
+
except Exception as e:
|
|
51
|
+
print_message(
|
|
52
|
+
f"[red]Error listing connected environments: {str(e)}[/red]",
|
|
53
|
+
ctx.obj["FORMAT"],
|
|
54
|
+
)
|
|
55
|
+
raise click.Abort()
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@connected_environments_group.command(name="get")
|
|
59
|
+
@click.argument("conn_env_id")
|
|
60
|
+
@click.option("--expand", help="Expand related entities")
|
|
61
|
+
@click.pass_context
|
|
62
|
+
def get(ctx, conn_env_id, expand):
|
|
63
|
+
"""Get a connected environment by ID"""
|
|
64
|
+
|
|
65
|
+
async def _run():
|
|
66
|
+
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
67
|
+
client = TestZeusClient(**config)
|
|
68
|
+
async with client:
|
|
69
|
+
if token:
|
|
70
|
+
initialize_client_with_token(client, token)
|
|
71
|
+
else:
|
|
72
|
+
await client.ensure_authenticated()
|
|
73
|
+
conn_env = await client.connected_environments.get_one(conn_env_id, expand=expand)
|
|
74
|
+
return conn_env.data
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
result = asyncio.run(_run())
|
|
78
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
79
|
+
except Exception as e:
|
|
80
|
+
print_message(
|
|
81
|
+
f"[red]Error getting connected environment: {str(e)}[/red]",
|
|
82
|
+
ctx.obj["FORMAT"],
|
|
83
|
+
)
|
|
84
|
+
raise click.Abort()
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@connected_environments_group.command(name="update")
|
|
88
|
+
@click.argument("conn_env_id")
|
|
89
|
+
@click.option("--name", required=True, help="New connected environment name")
|
|
90
|
+
@click.pass_context
|
|
91
|
+
def update(ctx, conn_env_id, name):
|
|
92
|
+
"""Update a connected environment's name"""
|
|
93
|
+
|
|
94
|
+
async def _run():
|
|
95
|
+
config, token, tenant_id, user_id = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
96
|
+
client = TestZeusClient(**config)
|
|
97
|
+
async with client:
|
|
98
|
+
if token:
|
|
99
|
+
initialize_client_with_token(client, token)
|
|
100
|
+
else:
|
|
101
|
+
await client.ensure_authenticated()
|
|
102
|
+
|
|
103
|
+
# Validate tenant ownership before updating.
|
|
104
|
+
conn_env = await client.connected_environments.get_one(conn_env_id)
|
|
105
|
+
validate_tenant_ownership(conn_env.data, tenant_id, "connected environment")
|
|
106
|
+
|
|
107
|
+
updates = {"tenant": tenant_id, "modified_by": user_id, "name": name}
|
|
108
|
+
updated = await client.connected_environments.update(conn_env_id, updates)
|
|
109
|
+
return updated.data
|
|
110
|
+
|
|
111
|
+
try:
|
|
112
|
+
result = asyncio.run(_run())
|
|
113
|
+
print_message(
|
|
114
|
+
"[green]Connected environment updated successfully[/green]",
|
|
115
|
+
ctx.obj["FORMAT"],
|
|
116
|
+
)
|
|
117
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
118
|
+
except Exception as e:
|
|
119
|
+
print_message(
|
|
120
|
+
f"[red]Error updating connected environment: {str(e)}[/red]",
|
|
121
|
+
ctx.obj["FORMAT"],
|
|
122
|
+
)
|
|
123
|
+
raise click.Abort()
|
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Connected environment management commands for TestZeus CLI.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
import asyncio
|
|
6
|
-
import click
|
|
7
|
-
from rich.console import Console
|
|
8
|
-
from testzeus_sdk import TestZeusClient
|
|
9
|
-
from testzeus_cli.config import get_client_config
|
|
10
|
-
from testzeus_cli.utils.formatters import format_output, print_message
|
|
11
|
-
from testzeus_cli.utils.auth import initialize_client_with_token
|
|
12
|
-
from testzeus_cli.utils.validators import parse_key_value_pairs, validate_tenant_ownership
|
|
13
|
-
|
|
14
|
-
console = Console()
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@click.group()
|
|
18
|
-
def connected_environments_group():
|
|
19
|
-
"""Manage connected environments in TestZeus"""
|
|
20
|
-
pass
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
@connected_environments_group.command(name="create")
|
|
24
|
-
@click.option("--name", required=True, help="Connected environment name")
|
|
25
|
-
@click.option("--connection", help="Connection ID or name to link with")
|
|
26
|
-
@click.option("--tags", help="Comma-separated list of tags")
|
|
27
|
-
@click.option(
|
|
28
|
-
"--metadata",
|
|
29
|
-
"-m",
|
|
30
|
-
multiple=True,
|
|
31
|
-
help="Metadata entries (format: key=value)",
|
|
32
|
-
)
|
|
33
|
-
@click.option(
|
|
34
|
-
"--skip-process",
|
|
35
|
-
is_flag=True,
|
|
36
|
-
default=False,
|
|
37
|
-
help="Skip processing on create",
|
|
38
|
-
)
|
|
39
|
-
@click.pass_context
|
|
40
|
-
def create(ctx, name, connection, tags, metadata, skip_process):
|
|
41
|
-
"""Create a new connected environment"""
|
|
42
|
-
|
|
43
|
-
async def _run():
|
|
44
|
-
config, token, stored_tenant_id, stored_user_id = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
45
|
-
client = TestZeusClient(**config)
|
|
46
|
-
|
|
47
|
-
async with client:
|
|
48
|
-
if token:
|
|
49
|
-
initialize_client_with_token(client, token)
|
|
50
|
-
else:
|
|
51
|
-
await client.ensure_authenticated()
|
|
52
|
-
|
|
53
|
-
params = {
|
|
54
|
-
"name": name,
|
|
55
|
-
"tenant": stored_tenant_id,
|
|
56
|
-
"modified_by": stored_user_id,
|
|
57
|
-
"skip_process": skip_process,
|
|
58
|
-
"metadata": parse_key_value_pairs(metadata) if metadata else {},
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if connection:
|
|
62
|
-
params["connection"] = connection
|
|
63
|
-
|
|
64
|
-
if tags:
|
|
65
|
-
params["tags"] = tags.split(",")
|
|
66
|
-
|
|
67
|
-
conn_env = await client.connected_environments.create(params)
|
|
68
|
-
return conn_env.data
|
|
69
|
-
|
|
70
|
-
try:
|
|
71
|
-
result = asyncio.run(_run())
|
|
72
|
-
print_message(
|
|
73
|
-
f"[green]Connected environment created successfully with ID: " f"{result['id']}[/green]",
|
|
74
|
-
ctx.obj["FORMAT"],
|
|
75
|
-
)
|
|
76
|
-
format_output(result, ctx.obj["FORMAT"])
|
|
77
|
-
except Exception as e:
|
|
78
|
-
print_message(
|
|
79
|
-
f"[red]Error creating connected environment: {str(e)}[/red]",
|
|
80
|
-
ctx.obj["FORMAT"],
|
|
81
|
-
)
|
|
82
|
-
raise click.Abort()
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
@connected_environments_group.command(name="list")
|
|
86
|
-
@click.option("--filters", "-f", multiple=True, help="Filter results (format: key=value)")
|
|
87
|
-
@click.option("--sort", help="Sort by field")
|
|
88
|
-
@click.option("--expand", help="Expand related entities")
|
|
89
|
-
@click.pass_context
|
|
90
|
-
def list(ctx, filters, sort, expand):
|
|
91
|
-
"""List all connected environments"""
|
|
92
|
-
|
|
93
|
-
async def _run():
|
|
94
|
-
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
95
|
-
client = TestZeusClient(**config)
|
|
96
|
-
filter_dict = parse_key_value_pairs(filters) if filters else {}
|
|
97
|
-
async with client:
|
|
98
|
-
if token:
|
|
99
|
-
initialize_client_with_token(client, token)
|
|
100
|
-
else:
|
|
101
|
-
await client.ensure_authenticated()
|
|
102
|
-
result = await client.connected_environments.get_list(expand=expand, sort=sort, filters=filter_dict)
|
|
103
|
-
return result
|
|
104
|
-
|
|
105
|
-
try:
|
|
106
|
-
result = asyncio.run(_run())
|
|
107
|
-
format_output(result, ctx.obj["FORMAT"])
|
|
108
|
-
except Exception as e:
|
|
109
|
-
print_message(
|
|
110
|
-
f"[red]Error listing connected environments: {str(e)}[/red]",
|
|
111
|
-
ctx.obj["FORMAT"],
|
|
112
|
-
)
|
|
113
|
-
raise click.Abort()
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
@connected_environments_group.command(name="get")
|
|
117
|
-
@click.argument("conn_env_id")
|
|
118
|
-
@click.option("--expand", help="Expand related entities")
|
|
119
|
-
@click.pass_context
|
|
120
|
-
def get(ctx, conn_env_id, expand):
|
|
121
|
-
"""Get a connected environment by ID"""
|
|
122
|
-
|
|
123
|
-
async def _run():
|
|
124
|
-
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
125
|
-
client = TestZeusClient(**config)
|
|
126
|
-
async with client:
|
|
127
|
-
if token:
|
|
128
|
-
initialize_client_with_token(client, token)
|
|
129
|
-
else:
|
|
130
|
-
await client.ensure_authenticated()
|
|
131
|
-
conn_env = await client.connected_environments.get_one(conn_env_id, expand=expand)
|
|
132
|
-
return conn_env.data
|
|
133
|
-
|
|
134
|
-
try:
|
|
135
|
-
result = asyncio.run(_run())
|
|
136
|
-
format_output(result, ctx.obj["FORMAT"])
|
|
137
|
-
except Exception as e:
|
|
138
|
-
print_message(
|
|
139
|
-
f"[red]Error getting connected environment: {str(e)}[/red]",
|
|
140
|
-
ctx.obj["FORMAT"],
|
|
141
|
-
)
|
|
142
|
-
raise click.Abort()
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
@connected_environments_group.command(name="update")
|
|
146
|
-
@click.argument("conn_env_id")
|
|
147
|
-
@click.option("--name", help="New connected environment name")
|
|
148
|
-
@click.option("--connection", help="Connection ID or name to link with")
|
|
149
|
-
@click.option("--tags", help="Comma-separated list of tags")
|
|
150
|
-
@click.option(
|
|
151
|
-
"--metadata",
|
|
152
|
-
"-m",
|
|
153
|
-
multiple=True,
|
|
154
|
-
help="Metadata entries (format: key=value)",
|
|
155
|
-
)
|
|
156
|
-
@click.option(
|
|
157
|
-
"--skip-process/--no-skip-process",
|
|
158
|
-
default=None,
|
|
159
|
-
help="Toggle processing skip",
|
|
160
|
-
)
|
|
161
|
-
@click.pass_context
|
|
162
|
-
def update(ctx, conn_env_id, name, connection, tags, metadata, skip_process):
|
|
163
|
-
"""Update a connected environment"""
|
|
164
|
-
|
|
165
|
-
async def _run():
|
|
166
|
-
config, token, tenant_id, user_id = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
167
|
-
client = TestZeusClient(**config)
|
|
168
|
-
async with client:
|
|
169
|
-
if token:
|
|
170
|
-
initialize_client_with_token(client, token)
|
|
171
|
-
else:
|
|
172
|
-
await client.ensure_authenticated()
|
|
173
|
-
|
|
174
|
-
# Validate tenant ownership before updating
|
|
175
|
-
conn_env = await client.connected_environments.get_one(conn_env_id)
|
|
176
|
-
validate_tenant_ownership(conn_env.data, tenant_id, "connected environment")
|
|
177
|
-
|
|
178
|
-
updates = {"tenant": tenant_id, "modified_by": user_id}
|
|
179
|
-
has_updates = False
|
|
180
|
-
|
|
181
|
-
if name:
|
|
182
|
-
updates["name"] = name
|
|
183
|
-
has_updates = True
|
|
184
|
-
|
|
185
|
-
if connection:
|
|
186
|
-
updates["connection"] = connection
|
|
187
|
-
has_updates = True
|
|
188
|
-
|
|
189
|
-
if tags and tags != "none":
|
|
190
|
-
updates["tags"] = tags.split(",")
|
|
191
|
-
has_updates = True
|
|
192
|
-
|
|
193
|
-
if tags == "none":
|
|
194
|
-
updates["tags"] = None
|
|
195
|
-
has_updates = True
|
|
196
|
-
|
|
197
|
-
if metadata:
|
|
198
|
-
updates["metadata"] = parse_key_value_pairs(metadata)
|
|
199
|
-
has_updates = True
|
|
200
|
-
|
|
201
|
-
if skip_process is not None:
|
|
202
|
-
updates["skip_process"] = skip_process
|
|
203
|
-
has_updates = True
|
|
204
|
-
|
|
205
|
-
if has_updates:
|
|
206
|
-
updated = await client.connected_environments.update(conn_env_id, updates)
|
|
207
|
-
return updated.data
|
|
208
|
-
else:
|
|
209
|
-
print_message("[yellow]No updates provided[/yellow]", ctx.obj["FORMAT"])
|
|
210
|
-
return None
|
|
211
|
-
|
|
212
|
-
try:
|
|
213
|
-
result = asyncio.run(_run())
|
|
214
|
-
print_message(
|
|
215
|
-
"[green]Connected environment updated successfully[/green]",
|
|
216
|
-
ctx.obj["FORMAT"],
|
|
217
|
-
)
|
|
218
|
-
format_output(result, ctx.obj["FORMAT"])
|
|
219
|
-
except Exception as e:
|
|
220
|
-
print_message(
|
|
221
|
-
f"[red]Error updating connected environment: {str(e)}[/red]",
|
|
222
|
-
ctx.obj["FORMAT"],
|
|
223
|
-
)
|
|
224
|
-
raise click.Abort()
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
@connected_environments_group.command(name="delete")
|
|
228
|
-
@click.argument("conn_env_id")
|
|
229
|
-
@click.pass_context
|
|
230
|
-
def delete(ctx, conn_env_id):
|
|
231
|
-
"""Delete a connected environment"""
|
|
232
|
-
|
|
233
|
-
async def _run():
|
|
234
|
-
config, token, stored_tenant_id, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
235
|
-
client = TestZeusClient(**config)
|
|
236
|
-
async with client:
|
|
237
|
-
if token:
|
|
238
|
-
initialize_client_with_token(client, token)
|
|
239
|
-
else:
|
|
240
|
-
await client.ensure_authenticated()
|
|
241
|
-
|
|
242
|
-
# Validate tenant ownership before deleting
|
|
243
|
-
conn_env = await client.connected_environments.get_one(conn_env_id)
|
|
244
|
-
validate_tenant_ownership(conn_env.data, stored_tenant_id, "connected environment")
|
|
245
|
-
|
|
246
|
-
await client.connected_environments.delete(conn_env_id)
|
|
247
|
-
return {"id": conn_env_id}
|
|
248
|
-
|
|
249
|
-
try:
|
|
250
|
-
result = asyncio.run(_run())
|
|
251
|
-
print_message(
|
|
252
|
-
f"[green]Connected environment {result['id']} deleted successfully[/green]",
|
|
253
|
-
ctx.obj["FORMAT"],
|
|
254
|
-
)
|
|
255
|
-
except Exception as e:
|
|
256
|
-
print_message(
|
|
257
|
-
f"[red]Error deleting connected environment: {str(e)}[/red]",
|
|
258
|
-
ctx.obj["FORMAT"],
|
|
259
|
-
)
|
|
260
|
-
raise click.Abort()
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
@connected_environments_group.command(name="add-code-file", help="Add a code file to a connected environment")
|
|
264
|
-
@click.argument("conn_env_id")
|
|
265
|
-
@click.argument("file_path", type=click.Path(exists=True))
|
|
266
|
-
@click.pass_context
|
|
267
|
-
def add_code_file(ctx, conn_env_id, file_path):
|
|
268
|
-
"""Add a code file to a connected environment"""
|
|
269
|
-
|
|
270
|
-
async def _run():
|
|
271
|
-
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
272
|
-
client = TestZeusClient(**config)
|
|
273
|
-
async with client:
|
|
274
|
-
if token:
|
|
275
|
-
initialize_client_with_token(client, token)
|
|
276
|
-
else:
|
|
277
|
-
await client.ensure_authenticated()
|
|
278
|
-
conn_env = await client.connected_environments.add_code_file(conn_env_id, file_path)
|
|
279
|
-
return conn_env.data
|
|
280
|
-
|
|
281
|
-
try:
|
|
282
|
-
result = asyncio.run(_run())
|
|
283
|
-
print_message(
|
|
284
|
-
f"[green]Code file added to connected environment {conn_env_id}[/green]",
|
|
285
|
-
ctx.obj["FORMAT"],
|
|
286
|
-
)
|
|
287
|
-
format_output(result, ctx.obj["FORMAT"])
|
|
288
|
-
except Exception as e:
|
|
289
|
-
print_message(f"[red]Error adding code file: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
290
|
-
raise click.Abort()
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
@connected_environments_group.command(name="remove-code-file", help="Remove a code file from a connected environment")
|
|
294
|
-
@click.argument("conn_env_id")
|
|
295
|
-
@click.argument("file_name")
|
|
296
|
-
@click.pass_context
|
|
297
|
-
def remove_code_file(ctx, conn_env_id, file_name):
|
|
298
|
-
"""Remove a code file from a connected environment"""
|
|
299
|
-
|
|
300
|
-
async def _run():
|
|
301
|
-
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
302
|
-
client = TestZeusClient(**config)
|
|
303
|
-
async with client:
|
|
304
|
-
if token:
|
|
305
|
-
initialize_client_with_token(client, token)
|
|
306
|
-
else:
|
|
307
|
-
await client.ensure_authenticated()
|
|
308
|
-
conn_env = await client.connected_environments.remove_code_file(conn_env_id, file_name)
|
|
309
|
-
return conn_env.data
|
|
310
|
-
|
|
311
|
-
try:
|
|
312
|
-
result = asyncio.run(_run())
|
|
313
|
-
print_message(
|
|
314
|
-
f"[green]Code file removed from connected environment {conn_env_id}[/green]",
|
|
315
|
-
ctx.obj["FORMAT"],
|
|
316
|
-
)
|
|
317
|
-
format_output(result, ctx.obj["FORMAT"])
|
|
318
|
-
except Exception as e:
|
|
319
|
-
print_message(f"[red]Error removing code file: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
320
|
-
raise click.Abort()
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
@connected_environments_group.command(
|
|
324
|
-
name="delete-all-code-files",
|
|
325
|
-
help="Remove all code files from a connected environment",
|
|
326
|
-
)
|
|
327
|
-
@click.argument("conn_env_id")
|
|
328
|
-
@click.pass_context
|
|
329
|
-
def delete_all_code_files(ctx, conn_env_id):
|
|
330
|
-
"""Remove all code files from a connected environment"""
|
|
331
|
-
|
|
332
|
-
async def _run():
|
|
333
|
-
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
334
|
-
client = TestZeusClient(**config)
|
|
335
|
-
async with client:
|
|
336
|
-
if token:
|
|
337
|
-
initialize_client_with_token(client, token)
|
|
338
|
-
else:
|
|
339
|
-
await client.ensure_authenticated()
|
|
340
|
-
conn_env = await client.connected_environments.remove_all_code_files(conn_env_id)
|
|
341
|
-
return conn_env.data
|
|
342
|
-
|
|
343
|
-
try:
|
|
344
|
-
result = asyncio.run(_run())
|
|
345
|
-
print_message(
|
|
346
|
-
f"[green]All code files removed from connected environment " f"{conn_env_id}[/green]",
|
|
347
|
-
ctx.obj["FORMAT"],
|
|
348
|
-
)
|
|
349
|
-
format_output(result, ctx.obj["FORMAT"])
|
|
350
|
-
except Exception as e:
|
|
351
|
-
print_message(f"[red]Error removing code files: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
352
|
-
raise click.Abort()
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
@connected_environments_group.command(name="add-metadata-file", help="Add a metadata file to a connected environment")
|
|
356
|
-
@click.argument("conn_env_id")
|
|
357
|
-
@click.argument("file_path", type=click.Path(exists=True))
|
|
358
|
-
@click.pass_context
|
|
359
|
-
def add_metadata_file(ctx, conn_env_id, file_path):
|
|
360
|
-
"""Add a metadata file to a connected environment"""
|
|
361
|
-
|
|
362
|
-
async def _run():
|
|
363
|
-
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
364
|
-
client = TestZeusClient(**config)
|
|
365
|
-
async with client:
|
|
366
|
-
if token:
|
|
367
|
-
initialize_client_with_token(client, token)
|
|
368
|
-
else:
|
|
369
|
-
await client.ensure_authenticated()
|
|
370
|
-
conn_env = await client.connected_environments.add_metadata_file(conn_env_id, file_path)
|
|
371
|
-
return conn_env.data
|
|
372
|
-
|
|
373
|
-
try:
|
|
374
|
-
result = asyncio.run(_run())
|
|
375
|
-
print_message(
|
|
376
|
-
f"[green]Metadata file added to connected environment {conn_env_id}[/green]",
|
|
377
|
-
ctx.obj["FORMAT"],
|
|
378
|
-
)
|
|
379
|
-
format_output(result, ctx.obj["FORMAT"])
|
|
380
|
-
except Exception as e:
|
|
381
|
-
print_message(f"[red]Error adding metadata file: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
382
|
-
raise click.Abort()
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
@connected_environments_group.command(
|
|
386
|
-
name="remove-metadata-file",
|
|
387
|
-
help="Remove a metadata file from a connected environment",
|
|
388
|
-
)
|
|
389
|
-
@click.argument("conn_env_id")
|
|
390
|
-
@click.argument("file_name")
|
|
391
|
-
@click.pass_context
|
|
392
|
-
def remove_metadata_file(ctx, conn_env_id, file_name):
|
|
393
|
-
"""Remove a metadata file from a connected environment"""
|
|
394
|
-
|
|
395
|
-
async def _run():
|
|
396
|
-
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
397
|
-
client = TestZeusClient(**config)
|
|
398
|
-
async with client:
|
|
399
|
-
if token:
|
|
400
|
-
initialize_client_with_token(client, token)
|
|
401
|
-
else:
|
|
402
|
-
await client.ensure_authenticated()
|
|
403
|
-
conn_env = await client.connected_environments.remove_metadata_file(conn_env_id, file_name)
|
|
404
|
-
return conn_env.data
|
|
405
|
-
|
|
406
|
-
try:
|
|
407
|
-
result = asyncio.run(_run())
|
|
408
|
-
print_message(
|
|
409
|
-
f"[green]Metadata file removed from connected environment " f"{conn_env_id}[/green]",
|
|
410
|
-
ctx.obj["FORMAT"],
|
|
411
|
-
)
|
|
412
|
-
format_output(result, ctx.obj["FORMAT"])
|
|
413
|
-
except Exception as e:
|
|
414
|
-
print_message(f"[red]Error removing metadata file: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
415
|
-
raise click.Abort()
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
@connected_environments_group.command(
|
|
419
|
-
name="delete-all-metadata-files",
|
|
420
|
-
help="Remove all metadata files from a connected environment",
|
|
421
|
-
)
|
|
422
|
-
@click.argument("conn_env_id")
|
|
423
|
-
@click.pass_context
|
|
424
|
-
def delete_all_metadata_files(ctx, conn_env_id):
|
|
425
|
-
"""Remove all metadata files from a connected environment"""
|
|
426
|
-
|
|
427
|
-
async def _run():
|
|
428
|
-
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
429
|
-
client = TestZeusClient(**config)
|
|
430
|
-
async with client:
|
|
431
|
-
if token:
|
|
432
|
-
initialize_client_with_token(client, token)
|
|
433
|
-
else:
|
|
434
|
-
await client.ensure_authenticated()
|
|
435
|
-
conn_env = await client.connected_environments.remove_all_metadata_files(conn_env_id)
|
|
436
|
-
return conn_env.data
|
|
437
|
-
|
|
438
|
-
try:
|
|
439
|
-
result = asyncio.run(_run())
|
|
440
|
-
print_message(
|
|
441
|
-
f"[green]All metadata files removed from connected environment " f"{conn_env_id}[/green]",
|
|
442
|
-
ctx.obj["FORMAT"],
|
|
443
|
-
)
|
|
444
|
-
format_output(result, ctx.obj["FORMAT"])
|
|
445
|
-
except Exception as e:
|
|
446
|
-
print_message(f"[red]Error removing metadata files: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
447
|
-
raise click.Abort()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|