blackant-sdk 1.0.2__tar.gz → 1.0.3__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.
Files changed (132) hide show
  1. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/PKG-INFO +2 -1
  2. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/pyproject.toml +5 -1
  3. blackant_sdk-1.0.3/src/blackant/cli.py +301 -0
  4. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant_sdk.egg-info/PKG-INFO +2 -1
  5. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant_sdk.egg-info/SOURCES.txt +2 -0
  6. blackant_sdk-1.0.3/src/blackant_sdk.egg-info/entry_points.txt +2 -0
  7. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant_sdk.egg-info/requires.txt +1 -0
  8. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/MANIFEST.in +0 -0
  9. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/README.md +0 -0
  10. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/_version.py +0 -0
  11. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/config/defaults.yaml +0 -0
  12. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/config/development.yaml +0 -0
  13. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/config/production.yaml +0 -0
  14. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/config/schema.yaml +0 -0
  15. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/docs/Makefile +0 -0
  16. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/docs/source/conf.py +0 -0
  17. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/docs/source/index.rst +0 -0
  18. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/docs/source/modules/api.rst +0 -0
  19. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/docs/source/modules/auth.rst +0 -0
  20. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/docs/source/modules/blackant.rst +0 -0
  21. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/docs/source/modules/config.rst +0 -0
  22. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/docs/source/modules/docker.rst +0 -0
  23. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/docs/source/modules/http.rst +0 -0
  24. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/docs/source/modules/patterns.rst +0 -0
  25. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/docs/source/modules/services.rst +0 -0
  26. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/docs/source/modules/utils.rst +0 -0
  27. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/examples/build_service_demo.py +0 -0
  28. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/requirements-dev.txt +0 -0
  29. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/requirements.debug.txt +0 -0
  30. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/requirements.txt +0 -0
  31. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/setup.cfg +0 -0
  32. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/setup.py +0 -0
  33. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/__init__.py +0 -0
  34. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/auth/__init__.py +0 -0
  35. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/auth/blackant_auth.py +0 -0
  36. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/auth/keycloak_manager.py +0 -0
  37. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/auth/request_id.py +0 -0
  38. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/auth/role_assignment.py +0 -0
  39. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/auth/tokens.py +0 -0
  40. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/client.py +0 -0
  41. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/config/__init__.py +0 -0
  42. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/config/docker_config.py +0 -0
  43. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/config/keycloak_admin_config.py +0 -0
  44. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/docker/__init__.py +0 -0
  45. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/docker/builder.py +0 -0
  46. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/docker/client.py +0 -0
  47. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/docker/dao.py +0 -0
  48. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/docker/registry.py +0 -0
  49. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/exceptions.py +0 -0
  50. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/http/__init__.py +0 -0
  51. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/http/client.py +0 -0
  52. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/patterns/__init__.py +0 -0
  53. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/patterns/singleton.py +0 -0
  54. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/services/__init__.py +0 -0
  55. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/services/dao.py +0 -0
  56. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/services/registry.py +0 -0
  57. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/utils/__init__.py +0 -0
  58. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/utils/initialization.py +0 -0
  59. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/utils/logging.py +0 -0
  60. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/utils/request_id.py +0 -0
  61. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant/utils/store.py +0 -0
  62. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant_sdk.egg-info/dependency_links.txt +0 -0
  63. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/blackant_sdk.egg-info/top_level.txt +0 -0
  64. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/calculation/__init__.py +0 -0
  65. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/calculation/base.py +0 -0
  66. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/calculation/errors.py +0 -0
  67. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/calculation/impl/__init__.py +0 -0
  68. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/calculation/impl/my_calculation.py +0 -0
  69. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/calculation/impl/simple_calc.py +0 -0
  70. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/calculation/impl/test.py +0 -0
  71. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/calculation/impl/test_calc.py +0 -0
  72. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/calculation/loader.py +0 -0
  73. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/healthcheck.py +0 -0
  74. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/notifinations/__init__.py +0 -0
  75. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/notifinations/mail_sender.py +0 -0
  76. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/server.py +0 -0
  77. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/server_status.py +0 -0
  78. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/storage/__init__.py +0 -0
  79. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/storage/errors.py +0 -0
  80. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/storage/factory.py +0 -0
  81. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/storage/interface.py +0 -0
  82. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/storage/minio.py +0 -0
  83. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/__init__.py +0 -0
  84. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/dao.py +0 -0
  85. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/errors.py +0 -0
  86. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/log_adapter.py +0 -0
  87. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/parsers/__init__.py +0 -0
  88. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/parsers/base.py +0 -0
  89. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/parsers/callback.py +0 -0
  90. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/parsers/cmd_args.py +0 -0
  91. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/parsers/freetext.py +0 -0
  92. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/parsers/objects.py +0 -0
  93. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/parsers/request.py +0 -0
  94. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/resource.py +0 -0
  95. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/states/__init__.py +0 -0
  96. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/states/base.py +0 -0
  97. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/states/error.py +0 -0
  98. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/states/idle.py +0 -0
  99. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/states/ready.py +0 -0
  100. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/states/running.py +0 -0
  101. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/states/set_up.py +0 -0
  102. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/states/tear_down.py +0 -0
  103. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/src/task/task.py +0 -0
  104. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/__init__.py +0 -0
  105. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/conftest.py +0 -0
  106. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/function/__init__.py +0 -0
  107. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/function/test_auth_operations.py +0 -0
  108. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/function/test_automatic_role_assignment.py +0 -0
  109. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/function/test_build_service_operations.py +0 -0
  110. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/function/test_client_credentials_operations.py +0 -0
  111. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/function/test_core_methods_integration.py +0 -0
  112. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/function/test_docker_operations.py +0 -0
  113. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/function/test_full_state_machine_e2e.py +0 -0
  114. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/function/test_remote_docker_build.py +0 -0
  115. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/function/test_service_operations.py +0 -0
  116. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/function/test_task_communication.py +0 -0
  117. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/__init__.py +0 -0
  118. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_auth_tokens.py +0 -0
  119. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_calculation_loader.py +0 -0
  120. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_client_credentials_auth.py +0 -0
  121. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_docker_builder.py +0 -0
  122. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_docker_dao.py +0 -0
  123. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_http.py +0 -0
  124. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_http_integration.py +0 -0
  125. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_keycloak_manager.py +0 -0
  126. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_logger.py +0 -0
  127. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_my_calculation.py +0 -0
  128. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_request_id.py +0 -0
  129. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_role_assignment.py +0 -0
  130. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_service_manager_dao.py +0 -0
  131. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_singleton.py +0 -0
  132. {blackant_sdk-1.0.2 → blackant_sdk-1.0.3}/test/unit/test_store.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blackant-sdk
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: Python SDK for Docker operations with automatic authentication through BlackAnt platform
5
5
  Author-email: Balázs Milán <milan.balazs@uni-obuda.hu>
6
6
  Maintainer-email: BlackAnt Development Team <dev@blackant.app>
@@ -31,6 +31,7 @@ Requires-Dist: gunicorn>=21.2.0
31
31
  Requires-Dist: colorama>=0.4.6
32
32
  Requires-Dist: python-keycloak>=3.0.0
33
33
  Requires-Dist: PyJWT>=2.8.0
34
+ Requires-Dist: click>=8.1.0
34
35
  Provides-Extra: dev
35
36
  Requires-Dist: pytest>=7.0.0; extra == "dev"
36
37
  Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "blackant-sdk"
7
- version = "1.0.2"
7
+ version = "1.0.3"
8
8
  description = "Python SDK for Docker operations with automatic authentication through BlackAnt platform"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -39,8 +39,12 @@ dependencies = [
39
39
  "colorama>=0.4.6",
40
40
  "python-keycloak>=3.0.0",
41
41
  "PyJWT>=2.8.0",
42
+ "click>=8.1.0",
42
43
  ]
43
44
 
45
+ [project.scripts]
46
+ blackant = "blackant.cli:main"
47
+
44
48
  [project.optional-dependencies]
45
49
  dev = [
46
50
  "pytest>=7.0.0",
@@ -0,0 +1,301 @@
1
+ """BlackAnt SDK Command Line Interface.
2
+
3
+ This module provides a CLI for the BlackAnt SDK, allowing users to
4
+ interact with the BlackAnt platform directly from the terminal.
5
+
6
+ Usage:
7
+ blackant login --user USER --password PASS --url URL
8
+ blackant build --name SERVICE_NAME --path PATH [--push]
9
+ blackant list
10
+ blackant status SERVICE_NAME
11
+ blackant delete SERVICE_NAME
12
+ """
13
+
14
+ import os
15
+ import sys
16
+ import click
17
+ from typing import Optional
18
+
19
+
20
+ def get_client(user: Optional[str] = None, password: Optional[str] = None,
21
+ base_url: Optional[str] = None, login_url: Optional[str] = None):
22
+ """Create and authenticate a BlackAnt client.
23
+
24
+ Args:
25
+ user: Username (or from BLACKANT_USER env var)
26
+ password: Password (or from BLACKANT_PASSWORD env var)
27
+ base_url: Base URL (or from BLACKANT_URL env var)
28
+ login_url: Login URL (or from BLACKANT_LOGIN_URL env var)
29
+
30
+ Returns:
31
+ Authenticated BlackAntClient instance
32
+
33
+ Raises:
34
+ click.ClickException: If authentication fails or credentials missing
35
+ """
36
+ from blackant import BlackAntClient
37
+
38
+ user = user or os.getenv("BLACKANT_USER")
39
+ password = password or os.getenv("BLACKANT_PASSWORD")
40
+ base_url = base_url or os.getenv("BLACKANT_URL", "https://dev.blackant.app")
41
+ login_url = login_url or os.getenv("BLACKANT_LOGIN_URL", f"{base_url}/api/auth/login")
42
+
43
+ if not user or not password:
44
+ raise click.ClickException(
45
+ "Missing credentials. Provide --user and --password, "
46
+ "or set BLACKANT_USER and BLACKANT_PASSWORD environment variables."
47
+ )
48
+
49
+ try:
50
+ client = BlackAntClient(
51
+ user=user,
52
+ password=password,
53
+ base_url=base_url,
54
+ login_url=login_url
55
+ )
56
+ if not client.authenticate():
57
+ raise click.ClickException("Authentication failed. Check your credentials.")
58
+ return client
59
+ except Exception as e:
60
+ raise click.ClickException(f"Failed to connect: {e}")
61
+
62
+
63
+ @click.group()
64
+ @click.version_option(version="1.0.3", prog_name="blackant")
65
+ def main():
66
+ """BlackAnt SDK - Command Line Interface
67
+
68
+ Interact with the BlackAnt platform from your terminal.
69
+
70
+ \b
71
+ Environment variables:
72
+ BLACKANT_USER - Username for authentication
73
+ BLACKANT_PASSWORD - Password for authentication
74
+ BLACKANT_URL - Base URL (default: https://dev.blackant.app)
75
+
76
+ \b
77
+ Examples:
78
+ blackant login --user admin --password xxx
79
+ blackant build --name my-calc --path ./src/calculation/impl --push
80
+ blackant list
81
+ blackant status my-calc
82
+ """
83
+ pass
84
+
85
+
86
+ @main.command()
87
+ @click.option("--user", "-u", help="BlackAnt username")
88
+ @click.option("--password", "-p", help="BlackAnt password")
89
+ @click.option("--url", help="BlackAnt base URL")
90
+ def login(user: Optional[str], password: Optional[str], url: Optional[str]):
91
+ """Test connection and authenticate with BlackAnt.
92
+
93
+ Verifies that the provided credentials are valid and the
94
+ BlackAnt platform is reachable.
95
+ """
96
+ client = get_client(user=user, password=password, base_url=url)
97
+
98
+ if client.test_connection():
99
+ click.secho("Successfully connected to BlackAnt!", fg="green")
100
+ click.echo(f" User: {user or os.getenv('BLACKANT_USER')}")
101
+ click.echo(f" URL: {url or os.getenv('BLACKANT_URL', 'https://dev.blackant.app')}")
102
+ else:
103
+ raise click.ClickException("Connection test failed.")
104
+
105
+
106
+ @main.command()
107
+ @click.option("--name", "-n", required=True, help="Service name")
108
+ @click.option("--path", "-p", required=True, help="Path to implementation directory")
109
+ @click.option("--dockerfile", "-d", default="Dockerfile", help="Dockerfile name (default: Dockerfile)")
110
+ @click.option("--tag", "-t", default="latest", help="Image tag (default: latest)")
111
+ @click.option("--push/--no-push", default=True, help="Push to registry after build (default: yes)")
112
+ @click.option("--register/--no-register", default=False, help="Register service after push (default: no)")
113
+ @click.option("--user", "-u", help="BlackAnt username")
114
+ @click.option("--password", help="BlackAnt password")
115
+ @click.option("--url", help="BlackAnt base URL")
116
+ def build(name: str, path: str, dockerfile: str, tag: str, push: bool,
117
+ register: bool, user: Optional[str], password: Optional[str],
118
+ url: Optional[str]):
119
+ """Build a Docker image and optionally push to registry.
120
+
121
+ \b
122
+ Examples:
123
+ blackant build --name my-calc --path ./src/calculation/impl
124
+ blackant build --name my-calc --path ./impl --tag v1.0.0 --push
125
+ blackant build --name my-calc --path ./impl --no-push
126
+ """
127
+ client = get_client(user=user, password=password, base_url=url)
128
+
129
+ click.echo(f"Building service '{name}' from {path}...")
130
+ click.echo(f" Dockerfile: {dockerfile}")
131
+ click.echo(f" Tag: {tag}")
132
+ click.echo(f" Push: {'yes' if push else 'no'}")
133
+
134
+ try:
135
+ result = client.build_service(
136
+ service_name=name,
137
+ impl_path=path,
138
+ dockerfile_path=dockerfile,
139
+ tag=tag,
140
+ push=push,
141
+ register_service=register
142
+ )
143
+
144
+ if result.get("build_success"):
145
+ click.secho("Build successful!", fg="green")
146
+ click.echo(f" Image: {result.get('full_image', 'N/A')}")
147
+ click.echo(f" Image ID: {result.get('image_id', 'N/A')[:12]}...")
148
+ size_mb = result.get('size', 0) / 1024 / 1024
149
+ click.echo(f" Size: {size_mb:.2f} MB")
150
+
151
+ if push and result.get("pushed"):
152
+ click.secho("Push successful!", fg="green")
153
+ elif push:
154
+ click.secho("Push failed!", fg="red")
155
+ else:
156
+ raise click.ClickException("Build failed. Check logs for details.")
157
+
158
+ except Exception as e:
159
+ raise click.ClickException(f"Build error: {e}")
160
+
161
+
162
+ @main.command("list")
163
+ @click.option("--namespace", "-ns", help="Filter by namespace")
164
+ @click.option("--user", "-u", help="BlackAnt username")
165
+ @click.option("--password", "-p", help="BlackAnt password")
166
+ @click.option("--url", help="BlackAnt base URL")
167
+ def list_services(namespace: Optional[str], user: Optional[str],
168
+ password: Optional[str], url: Optional[str]):
169
+ """List all registered services.
170
+
171
+ \b
172
+ Examples:
173
+ blackant list
174
+ blackant list --namespace production
175
+ """
176
+ client = get_client(user=user, password=password, base_url=url)
177
+
178
+ try:
179
+ services = client.list_services(namespace=namespace)
180
+
181
+ if not services:
182
+ click.echo("No services found.")
183
+ return
184
+
185
+ click.echo(f"Found {len(services)} service(s):\n")
186
+
187
+ for svc in services:
188
+ name = svc.get("name", "Unknown")
189
+ status = svc.get("status", "Unknown")
190
+ svc_type = svc.get("type", "Unknown")
191
+
192
+ # Color based on status
193
+ if status.lower() in ("running", "active"):
194
+ status_color = "green"
195
+ elif status.lower() in ("stopped", "inactive"):
196
+ status_color = "yellow"
197
+ else:
198
+ status_color = "white"
199
+
200
+ click.echo(f" {name}")
201
+ click.echo(f" Status: ", nl=False)
202
+ click.secho(status, fg=status_color)
203
+ click.echo(f" Type: {svc_type}")
204
+ click.echo()
205
+
206
+ except Exception as e:
207
+ raise click.ClickException(f"Failed to list services: {e}")
208
+
209
+
210
+ @main.command()
211
+ @click.argument("name")
212
+ @click.option("--user", "-u", help="BlackAnt username")
213
+ @click.option("--password", "-p", help="BlackAnt password")
214
+ @click.option("--url", help="BlackAnt base URL")
215
+ def status(name: str, user: Optional[str], password: Optional[str],
216
+ url: Optional[str]):
217
+ """Get status of a specific service.
218
+
219
+ \b
220
+ Examples:
221
+ blackant status my-calc
222
+ blackant status my-service --user admin --password xxx
223
+ """
224
+ client = get_client(user=user, password=password, base_url=url)
225
+
226
+ try:
227
+ svc_status = client.get_service_status(service_name=name)
228
+
229
+ click.echo(f"Service: {name}\n")
230
+
231
+ for key, value in svc_status.items():
232
+ click.echo(f" {key}: {value}")
233
+
234
+ except Exception as e:
235
+ raise click.ClickException(f"Failed to get status: {e}")
236
+
237
+
238
+ @main.command()
239
+ @click.argument("name")
240
+ @click.option("--yes", "-y", is_flag=True, help="Skip confirmation")
241
+ @click.option("--user", "-u", help="BlackAnt username")
242
+ @click.option("--password", "-p", help="BlackAnt password")
243
+ @click.option("--url", help="BlackAnt base URL")
244
+ def delete(name: str, yes: bool, user: Optional[str], password: Optional[str],
245
+ url: Optional[str]):
246
+ """Delete a service.
247
+
248
+ \b
249
+ Examples:
250
+ blackant delete my-calc
251
+ blackant delete my-calc --yes
252
+ """
253
+ if not yes:
254
+ click.confirm(f"Are you sure you want to delete '{name}'?", abort=True)
255
+
256
+ client = get_client(user=user, password=password, base_url=url)
257
+
258
+ try:
259
+ if client.delete_service(service_name=name):
260
+ click.secho(f"Service '{name}' deleted successfully!", fg="green")
261
+ else:
262
+ raise click.ClickException(f"Failed to delete service '{name}'.")
263
+
264
+ except Exception as e:
265
+ raise click.ClickException(f"Delete error: {e}")
266
+
267
+
268
+ @main.command()
269
+ @click.argument("name")
270
+ @click.option("--user", "-u", help="BlackAnt username")
271
+ @click.option("--password", "-p", help="BlackAnt password")
272
+ @click.option("--url", help="BlackAnt base URL")
273
+ def info(name: str, user: Optional[str], password: Optional[str],
274
+ url: Optional[str]):
275
+ """Get detailed information about a service.
276
+
277
+ \b
278
+ Examples:
279
+ blackant info my-calc
280
+ """
281
+ client = get_client(user=user, password=password, base_url=url)
282
+
283
+ try:
284
+ service = client.get_service(service_name=name)
285
+
286
+ click.echo(f"Service: {name}\n")
287
+
288
+ for key, value in service.items():
289
+ if isinstance(value, dict):
290
+ click.echo(f" {key}:")
291
+ for k, v in value.items():
292
+ click.echo(f" {k}: {v}")
293
+ else:
294
+ click.echo(f" {key}: {value}")
295
+
296
+ except Exception as e:
297
+ raise click.ClickException(f"Failed to get service info: {e}")
298
+
299
+
300
+ if __name__ == "__main__":
301
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blackant-sdk
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: Python SDK for Docker operations with automatic authentication through BlackAnt platform
5
5
  Author-email: Balázs Milán <milan.balazs@uni-obuda.hu>
6
6
  Maintainer-email: BlackAnt Development Team <dev@blackant.app>
@@ -31,6 +31,7 @@ Requires-Dist: gunicorn>=21.2.0
31
31
  Requires-Dist: colorama>=0.4.6
32
32
  Requires-Dist: python-keycloak>=3.0.0
33
33
  Requires-Dist: PyJWT>=2.8.0
34
+ Requires-Dist: click>=8.1.0
34
35
  Provides-Extra: dev
35
36
  Requires-Dist: pytest>=7.0.0; extra == "dev"
36
37
  Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
@@ -27,6 +27,7 @@ src/healthcheck.py
27
27
  src/server.py
28
28
  src/server_status.py
29
29
  src/blackant/__init__.py
30
+ src/blackant/cli.py
30
31
  src/blackant/client.py
31
32
  src/blackant/exceptions.py
32
33
  src/blackant/auth/__init__.py
@@ -58,6 +59,7 @@ src/blackant/utils/store.py
58
59
  src/blackant_sdk.egg-info/PKG-INFO
59
60
  src/blackant_sdk.egg-info/SOURCES.txt
60
61
  src/blackant_sdk.egg-info/dependency_links.txt
62
+ src/blackant_sdk.egg-info/entry_points.txt
61
63
  src/blackant_sdk.egg-info/requires.txt
62
64
  src/blackant_sdk.egg-info/top_level.txt
63
65
  src/calculation/__init__.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ blackant = blackant.cli:main
@@ -9,6 +9,7 @@ gunicorn>=21.2.0
9
9
  colorama>=0.4.6
10
10
  python-keycloak>=3.0.0
11
11
  PyJWT>=2.8.0
12
+ click>=8.1.0
12
13
 
13
14
  [dev]
14
15
  pytest>=7.0.0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes