licos-platform-cli 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {licos_platform_cli-0.1.0 → licos_platform_cli-0.2.0}/.gitignore +2 -0
- licos_platform_cli-0.2.0/PKG-INFO +6 -0
- {licos_platform_cli-0.1.0 → licos_platform_cli-0.2.0}/pyproject.toml +3 -3
- {licos_platform_cli-0.1.0 → licos_platform_cli-0.2.0}/src/licos_platform_cli/main.py +1 -26
- {licos_platform_cli-0.1.0 → licos_platform_cli-0.2.0}/tests/test_cli.py +29 -2
- licos_platform_cli-0.1.0/PKG-INFO +0 -6
- {licos_platform_cli-0.1.0 → licos_platform_cli-0.2.0}/src/licos_platform_cli/__init__.py +0 -0
|
@@ -4,11 +4,11 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "licos-platform-cli"
|
|
7
|
-
version = "0.
|
|
8
|
-
description = "LICOS platform CLI for storage operations"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "LICOS platform CLI for storage preview and download operations"
|
|
9
9
|
requires-python = ">=3.10"
|
|
10
10
|
dependencies = [
|
|
11
|
-
"licos-platform-sdk>=0.
|
|
11
|
+
"licos-platform-sdk>=0.2.0",
|
|
12
12
|
]
|
|
13
13
|
|
|
14
14
|
[project.scripts]
|
|
@@ -5,7 +5,7 @@ import json
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import Sequence
|
|
7
7
|
|
|
8
|
-
from licos_platform_sdk import download, download_url, preview_url
|
|
8
|
+
from licos_platform_sdk import download, download_url, preview_url
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def _build_parser() -> argparse.ArgumentParser:
|
|
@@ -15,17 +15,6 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
15
15
|
storage = subparsers.add_parser("storage", help="Platform storage operations")
|
|
16
16
|
storage_subparsers = storage.add_subparsers(dest="storage_command", required=True)
|
|
17
17
|
|
|
18
|
-
upload_user_cmd = storage_subparsers.add_parser("upload-user", help="Upload into the user bucket")
|
|
19
|
-
upload_user_cmd.add_argument("file", help="File path to upload")
|
|
20
|
-
|
|
21
|
-
upload_project_cmd = storage_subparsers.add_parser(
|
|
22
|
-
"upload-project",
|
|
23
|
-
help="Upload into the current user's project bucket",
|
|
24
|
-
)
|
|
25
|
-
upload_project_cmd.add_argument("file", help="File path to upload")
|
|
26
|
-
upload_project_cmd.add_argument("--project-id", help="Override LICOS_PROJECT_ID")
|
|
27
|
-
upload_project_cmd.add_argument("--user-id", help="Override LICOS_USER_ID")
|
|
28
|
-
|
|
29
18
|
preview_url_cmd = storage_subparsers.add_parser("preview-url", help="Build a public preview URL")
|
|
30
19
|
preview_url_cmd.add_argument("bucket", help="Bucket name")
|
|
31
20
|
preview_url_cmd.add_argument("object_key", help="Object key")
|
|
@@ -52,20 +41,6 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|
|
52
41
|
if args.command != "storage":
|
|
53
42
|
parser.error(f"Unsupported command: {args.command}")
|
|
54
43
|
|
|
55
|
-
if args.storage_command == "upload-user":
|
|
56
|
-
result = upload_user(args.file)
|
|
57
|
-
_print_json(result.to_dict())
|
|
58
|
-
return 0
|
|
59
|
-
|
|
60
|
-
if args.storage_command == "upload-project":
|
|
61
|
-
result = upload_project(
|
|
62
|
-
args.file,
|
|
63
|
-
project_id=args.project_id,
|
|
64
|
-
user_id=args.user_id,
|
|
65
|
-
)
|
|
66
|
-
_print_json(result.to_dict())
|
|
67
|
-
return 0
|
|
68
|
-
|
|
69
44
|
if args.storage_command == "preview-url":
|
|
70
45
|
_print_json(
|
|
71
46
|
{
|
|
@@ -10,7 +10,34 @@ from pathlib import Path
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class PlatformCliTests(unittest.TestCase):
|
|
13
|
-
def
|
|
13
|
+
def test_storage_help_does_not_expose_minio_upload_commands(self) -> None:
|
|
14
|
+
env = os.environ.copy()
|
|
15
|
+
env["PYTHONPATH"] = os.pathsep.join(
|
|
16
|
+
[
|
|
17
|
+
str(Path(__file__).resolve().parents[2] / "licos-platform-sdk" / "src"),
|
|
18
|
+
str(Path(__file__).resolve().parents[1] / "src"),
|
|
19
|
+
env.get("PYTHONPATH", ""),
|
|
20
|
+
]
|
|
21
|
+
).strip(os.pathsep)
|
|
22
|
+
|
|
23
|
+
proc = subprocess.run(
|
|
24
|
+
[
|
|
25
|
+
sys.executable,
|
|
26
|
+
"-m",
|
|
27
|
+
"licos_platform_cli.main",
|
|
28
|
+
"storage",
|
|
29
|
+
"--help",
|
|
30
|
+
],
|
|
31
|
+
capture_output=True,
|
|
32
|
+
check=True,
|
|
33
|
+
text=True,
|
|
34
|
+
env=env,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
self.assertNotIn("upload-user", proc.stdout)
|
|
38
|
+
self.assertNotIn("upload-project", proc.stdout)
|
|
39
|
+
|
|
40
|
+
def test_preview_url_command_prints_json(self) -> None:
|
|
14
41
|
with tempfile.TemporaryDirectory() as tmp_dir:
|
|
15
42
|
file_path = Path(tmp_dir) / "demo.txt"
|
|
16
43
|
file_path.write_text("hello world", encoding="utf-8")
|
|
@@ -23,7 +50,7 @@ class PlatformCliTests(unittest.TestCase):
|
|
|
23
50
|
]
|
|
24
51
|
).strip(os.pathsep)
|
|
25
52
|
env["LICOS_ORCHESTRATOR_API_BASE_URL"] = "http://127.0.0.1:9"
|
|
26
|
-
env["LICOS_USER_TOKEN"] = "
|
|
53
|
+
env["LICOS_USER_TOKEN"] = "user_token"
|
|
27
54
|
env["LICOS_USER_ID"] = "demo-user"
|
|
28
55
|
env["LICOS_PROJECT_ID"] = "demo-project"
|
|
29
56
|
|
|
File without changes
|