blackant-sdk 1.0.2__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 (130) hide show
  1. blackant_sdk-1.0.2/MANIFEST.in +35 -0
  2. blackant_sdk-1.0.2/PKG-INFO +117 -0
  3. blackant_sdk-1.0.2/README.md +70 -0
  4. blackant_sdk-1.0.2/_version.py +4 -0
  5. blackant_sdk-1.0.2/config/defaults.yaml +0 -0
  6. blackant_sdk-1.0.2/config/development.yaml +0 -0
  7. blackant_sdk-1.0.2/config/production.yaml +0 -0
  8. blackant_sdk-1.0.2/config/schema.yaml +0 -0
  9. blackant_sdk-1.0.2/docs/Makefile +17 -0
  10. blackant_sdk-1.0.2/docs/source/conf.py +64 -0
  11. blackant_sdk-1.0.2/docs/source/index.rst +273 -0
  12. blackant_sdk-1.0.2/docs/source/modules/api.rst +56 -0
  13. blackant_sdk-1.0.2/docs/source/modules/auth.rst +75 -0
  14. blackant_sdk-1.0.2/docs/source/modules/blackant.rst +48 -0
  15. blackant_sdk-1.0.2/docs/source/modules/config.rst +81 -0
  16. blackant_sdk-1.0.2/docs/source/modules/docker.rst +86 -0
  17. blackant_sdk-1.0.2/docs/source/modules/http.rst +62 -0
  18. blackant_sdk-1.0.2/docs/source/modules/patterns.rst +26 -0
  19. blackant_sdk-1.0.2/docs/source/modules/services.rst +66 -0
  20. blackant_sdk-1.0.2/docs/source/modules/utils.rst +93 -0
  21. blackant_sdk-1.0.2/examples/build_service_demo.py +205 -0
  22. blackant_sdk-1.0.2/pyproject.toml +131 -0
  23. blackant_sdk-1.0.2/requirements-dev.txt +0 -0
  24. blackant_sdk-1.0.2/requirements.debug.txt +1 -0
  25. blackant_sdk-1.0.2/requirements.txt +11 -0
  26. blackant_sdk-1.0.2/setup.cfg +4 -0
  27. blackant_sdk-1.0.2/setup.py +16 -0
  28. blackant_sdk-1.0.2/src/blackant/__init__.py +31 -0
  29. blackant_sdk-1.0.2/src/blackant/auth/__init__.py +10 -0
  30. blackant_sdk-1.0.2/src/blackant/auth/blackant_auth.py +518 -0
  31. blackant_sdk-1.0.2/src/blackant/auth/keycloak_manager.py +363 -0
  32. blackant_sdk-1.0.2/src/blackant/auth/request_id.py +52 -0
  33. blackant_sdk-1.0.2/src/blackant/auth/role_assignment.py +443 -0
  34. blackant_sdk-1.0.2/src/blackant/auth/tokens.py +57 -0
  35. blackant_sdk-1.0.2/src/blackant/client.py +400 -0
  36. blackant_sdk-1.0.2/src/blackant/config/__init__.py +0 -0
  37. blackant_sdk-1.0.2/src/blackant/config/docker_config.py +457 -0
  38. blackant_sdk-1.0.2/src/blackant/config/keycloak_admin_config.py +107 -0
  39. blackant_sdk-1.0.2/src/blackant/docker/__init__.py +12 -0
  40. blackant_sdk-1.0.2/src/blackant/docker/builder.py +616 -0
  41. blackant_sdk-1.0.2/src/blackant/docker/client.py +983 -0
  42. blackant_sdk-1.0.2/src/blackant/docker/dao.py +462 -0
  43. blackant_sdk-1.0.2/src/blackant/docker/registry.py +172 -0
  44. blackant_sdk-1.0.2/src/blackant/exceptions.py +111 -0
  45. blackant_sdk-1.0.2/src/blackant/http/__init__.py +8 -0
  46. blackant_sdk-1.0.2/src/blackant/http/client.py +125 -0
  47. blackant_sdk-1.0.2/src/blackant/patterns/__init__.py +1 -0
  48. blackant_sdk-1.0.2/src/blackant/patterns/singleton.py +20 -0
  49. blackant_sdk-1.0.2/src/blackant/services/__init__.py +10 -0
  50. blackant_sdk-1.0.2/src/blackant/services/dao.py +414 -0
  51. blackant_sdk-1.0.2/src/blackant/services/registry.py +635 -0
  52. blackant_sdk-1.0.2/src/blackant/utils/__init__.py +8 -0
  53. blackant_sdk-1.0.2/src/blackant/utils/initialization.py +32 -0
  54. blackant_sdk-1.0.2/src/blackant/utils/logging.py +337 -0
  55. blackant_sdk-1.0.2/src/blackant/utils/request_id.py +13 -0
  56. blackant_sdk-1.0.2/src/blackant/utils/store.py +50 -0
  57. blackant_sdk-1.0.2/src/blackant_sdk.egg-info/PKG-INFO +117 -0
  58. blackant_sdk-1.0.2/src/blackant_sdk.egg-info/SOURCES.txt +128 -0
  59. blackant_sdk-1.0.2/src/blackant_sdk.egg-info/dependency_links.txt +1 -0
  60. blackant_sdk-1.0.2/src/blackant_sdk.egg-info/requires.txt +27 -0
  61. blackant_sdk-1.0.2/src/blackant_sdk.egg-info/top_level.txt +5 -0
  62. blackant_sdk-1.0.2/src/calculation/__init__.py +0 -0
  63. blackant_sdk-1.0.2/src/calculation/base.py +26 -0
  64. blackant_sdk-1.0.2/src/calculation/errors.py +2 -0
  65. blackant_sdk-1.0.2/src/calculation/impl/__init__.py +0 -0
  66. blackant_sdk-1.0.2/src/calculation/impl/my_calculation.py +144 -0
  67. blackant_sdk-1.0.2/src/calculation/impl/simple_calc.py +53 -0
  68. blackant_sdk-1.0.2/src/calculation/impl/test.py +1 -0
  69. blackant_sdk-1.0.2/src/calculation/impl/test_calc.py +36 -0
  70. blackant_sdk-1.0.2/src/calculation/loader.py +227 -0
  71. blackant_sdk-1.0.2/src/healthcheck.py +31 -0
  72. blackant_sdk-1.0.2/src/notifinations/__init__.py +8 -0
  73. blackant_sdk-1.0.2/src/notifinations/mail_sender.py +212 -0
  74. blackant_sdk-1.0.2/src/server.py +38 -0
  75. blackant_sdk-1.0.2/src/server_status.py +31 -0
  76. blackant_sdk-1.0.2/src/storage/__init__.py +0 -0
  77. blackant_sdk-1.0.2/src/storage/errors.py +10 -0
  78. blackant_sdk-1.0.2/src/storage/factory.py +26 -0
  79. blackant_sdk-1.0.2/src/storage/interface.py +19 -0
  80. blackant_sdk-1.0.2/src/storage/minio.py +106 -0
  81. blackant_sdk-1.0.2/src/task/__init__.py +0 -0
  82. blackant_sdk-1.0.2/src/task/dao.py +38 -0
  83. blackant_sdk-1.0.2/src/task/errors.py +10 -0
  84. blackant_sdk-1.0.2/src/task/log_adapter.py +11 -0
  85. blackant_sdk-1.0.2/src/task/parsers/__init__.py +0 -0
  86. blackant_sdk-1.0.2/src/task/parsers/base.py +13 -0
  87. blackant_sdk-1.0.2/src/task/parsers/callback.py +40 -0
  88. blackant_sdk-1.0.2/src/task/parsers/cmd_args.py +52 -0
  89. blackant_sdk-1.0.2/src/task/parsers/freetext.py +19 -0
  90. blackant_sdk-1.0.2/src/task/parsers/objects.py +50 -0
  91. blackant_sdk-1.0.2/src/task/parsers/request.py +56 -0
  92. blackant_sdk-1.0.2/src/task/resource.py +84 -0
  93. blackant_sdk-1.0.2/src/task/states/__init__.py +0 -0
  94. blackant_sdk-1.0.2/src/task/states/base.py +14 -0
  95. blackant_sdk-1.0.2/src/task/states/error.py +47 -0
  96. blackant_sdk-1.0.2/src/task/states/idle.py +12 -0
  97. blackant_sdk-1.0.2/src/task/states/ready.py +51 -0
  98. blackant_sdk-1.0.2/src/task/states/running.py +21 -0
  99. blackant_sdk-1.0.2/src/task/states/set_up.py +40 -0
  100. blackant_sdk-1.0.2/src/task/states/tear_down.py +29 -0
  101. blackant_sdk-1.0.2/src/task/task.py +358 -0
  102. blackant_sdk-1.0.2/test/__init__.py +0 -0
  103. blackant_sdk-1.0.2/test/conftest.py +239 -0
  104. blackant_sdk-1.0.2/test/function/__init__.py +0 -0
  105. blackant_sdk-1.0.2/test/function/test_auth_operations.py +64 -0
  106. blackant_sdk-1.0.2/test/function/test_automatic_role_assignment.py +294 -0
  107. blackant_sdk-1.0.2/test/function/test_build_service_operations.py +428 -0
  108. blackant_sdk-1.0.2/test/function/test_client_credentials_operations.py +181 -0
  109. blackant_sdk-1.0.2/test/function/test_core_methods_integration.py +185 -0
  110. blackant_sdk-1.0.2/test/function/test_docker_operations.py +136 -0
  111. blackant_sdk-1.0.2/test/function/test_full_state_machine_e2e.py +446 -0
  112. blackant_sdk-1.0.2/test/function/test_remote_docker_build.py +288 -0
  113. blackant_sdk-1.0.2/test/function/test_service_operations.py +187 -0
  114. blackant_sdk-1.0.2/test/function/test_task_communication.py +138 -0
  115. blackant_sdk-1.0.2/test/unit/__init__.py +0 -0
  116. blackant_sdk-1.0.2/test/unit/test_auth_tokens.py +72 -0
  117. blackant_sdk-1.0.2/test/unit/test_calculation_loader.py +352 -0
  118. blackant_sdk-1.0.2/test/unit/test_client_credentials_auth.py +276 -0
  119. blackant_sdk-1.0.2/test/unit/test_docker_builder.py +409 -0
  120. blackant_sdk-1.0.2/test/unit/test_docker_dao.py +763 -0
  121. blackant_sdk-1.0.2/test/unit/test_http.py +181 -0
  122. blackant_sdk-1.0.2/test/unit/test_http_integration.py +90 -0
  123. blackant_sdk-1.0.2/test/unit/test_keycloak_manager.py +274 -0
  124. blackant_sdk-1.0.2/test/unit/test_logger.py +53 -0
  125. blackant_sdk-1.0.2/test/unit/test_my_calculation.py +263 -0
  126. blackant_sdk-1.0.2/test/unit/test_request_id.py +70 -0
  127. blackant_sdk-1.0.2/test/unit/test_role_assignment.py +228 -0
  128. blackant_sdk-1.0.2/test/unit/test_service_manager_dao.py +374 -0
  129. blackant_sdk-1.0.2/test/unit/test_singleton.py +55 -0
  130. blackant_sdk-1.0.2/test/unit/test_store.py +57 -0
@@ -0,0 +1,35 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGELOG.md
4
+ include requirements.txt
5
+ include requirements-dev.txt
6
+ include requirements.debug.txt
7
+ include pyproject.toml
8
+ include setup.py
9
+ include _version.py
10
+
11
+ recursive-include src *.py
12
+ recursive-include docs *.rst *.md *.py Makefile
13
+ recursive-include config *.yml *.yaml *.json
14
+ recursive-include examples *.py *.md *.yml *.yaml
15
+ recursive-include test *.py
16
+
17
+ exclude .gitignore
18
+ exclude .gitlab-ci.yml
19
+ exclude docker-compose*.yml
20
+ exclude Dockerfile
21
+ exclude docker-entrypoint.sh
22
+ exclude .dockerignore
23
+ exclude build_docs.sh
24
+ exclude publish.sh
25
+
26
+ recursive-exclude * __pycache__
27
+ recursive-exclude * *.py[co]
28
+ recursive-exclude * .DS_Store
29
+ recursive-exclude * *.so
30
+ recursive-exclude .git *
31
+ recursive-exclude .venv *
32
+ recursive-exclude .pytest_cache *
33
+ recursive-exclude htmlcov *
34
+ recursive-exclude dist *
35
+ recursive-exclude build *
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.4
2
+ Name: blackant-sdk
3
+ Version: 1.0.2
4
+ Summary: Python SDK for Docker operations with automatic authentication through BlackAnt platform
5
+ Author-email: Balázs Milán <milan.balazs@uni-obuda.hu>
6
+ Maintainer-email: BlackAnt Development Team <dev@blackant.app>
7
+ License: Proprietary - Óbudai Egyetem
8
+ Project-URL: Homepage, https://env.blackant.app/systemdevelopers/blackant_sdk
9
+ Project-URL: Documentation, https://docs.blackant.app
10
+ Project-URL: Repository, https://env.blackant.app/systemdevelopers/blackant_sdk
11
+ Project-URL: Bug Tracker, https://env.blackant.app/systemdevelopers/blackant_sdk/-/issues
12
+ Keywords: docker,sdk,authentication,blackant,container,orchestration,swarm
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: System :: Distributed Computing
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Operating System :: OS Independent
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: flask>=2.3.2
24
+ Requires-Dist: flask-restful>=0.3.10
25
+ Requires-Dist: waitress>=2.1.2
26
+ Requires-Dist: minio>=6.0.0
27
+ Requires-Dist: requests>=2.31.0
28
+ Requires-Dist: docker>=4.4.3
29
+ Requires-Dist: urllib3<2.0
30
+ Requires-Dist: gunicorn>=21.2.0
31
+ Requires-Dist: colorama>=0.4.6
32
+ Requires-Dist: python-keycloak>=3.0.0
33
+ Requires-Dist: PyJWT>=2.8.0
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
36
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
37
+ Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
38
+ Requires-Dist: sphinx>=5.0.0; extra == "dev"
39
+ Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "dev"
40
+ Provides-Extra: test
41
+ Requires-Dist: pytest>=7.0.0; extra == "test"
42
+ Requires-Dist: pytest-cov>=4.0.0; extra == "test"
43
+ Requires-Dist: pytest-mock>=3.10.0; extra == "test"
44
+ Provides-Extra: docs
45
+ Requires-Dist: sphinx>=5.0.0; extra == "docs"
46
+ Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"
47
+
48
+ # Python REST API docker template
49
+
50
+ A simple template to implement REST APIs using Python Flask & docker.
51
+
52
+ ## Build arguments
53
+
54
+ ### INSTALL_DEBUG_TOOLS
55
+
56
+ If it's set to True, ptvsd is installed during build to be able to do live debugging.
57
+
58
+ ## Environment variables
59
+
60
+ ### CALCULATION_NAME
61
+
62
+ Name of the calculation. Mandatory parameter.
63
+
64
+ ### SERVER_PORT
65
+
66
+ Port which on the server runs. Default: 5000
67
+
68
+ ### DEBUG_MODE
69
+
70
+ A switch to select between debug and release mode. If it is set to True, a Flask server will be started in debug mode and a ptvsd server. Otherwise, it is served using gevent production server. Default: False
71
+
72
+ ### OBJECT_STORAGE_URL
73
+
74
+ Url for the object storage. Mandatory if the code uses object storage.
75
+
76
+ ### OBJECT_STORAGE_ACCESS_KEY
77
+
78
+ Public key for the object storage.
79
+
80
+ ### OBJECT_STORAGE_SECRET_KEY
81
+
82
+ Private key for the object storage.
83
+
84
+ ### SCHEDULER_URL
85
+
86
+ Callback url of the scheduler.
87
+
88
+ ## Commands
89
+
90
+ ### Build
91
+
92
+ ```sh
93
+ docker-compose build
94
+ ```
95
+
96
+ ### Run
97
+
98
+ ```sh
99
+ docker-compose up
100
+ ```
101
+
102
+ ### Create task
103
+
104
+ You can use the tools/send_request.py script to send a simple request to the calculation container.
105
+
106
+ ### Debug
107
+
108
+ If you use Visual Studio Code, there is a debug configuration called Python: Remote Attach which will start a debug session and connect to your running container.
109
+
110
+ ## Documentation
111
+
112
+ Full HTML and PDF documentation can be generated from any revision using the generate_documentation job in the CI.
113
+ After the job have run successfully, the artifacts are stored for one day.
114
+ If it's necessary it can be rerun any time.
115
+
116
+
117
+ ......
@@ -0,0 +1,70 @@
1
+ # Python REST API docker template
2
+
3
+ A simple template to implement REST APIs using Python Flask & docker.
4
+
5
+ ## Build arguments
6
+
7
+ ### INSTALL_DEBUG_TOOLS
8
+
9
+ If it's set to True, ptvsd is installed during build to be able to do live debugging.
10
+
11
+ ## Environment variables
12
+
13
+ ### CALCULATION_NAME
14
+
15
+ Name of the calculation. Mandatory parameter.
16
+
17
+ ### SERVER_PORT
18
+
19
+ Port which on the server runs. Default: 5000
20
+
21
+ ### DEBUG_MODE
22
+
23
+ A switch to select between debug and release mode. If it is set to True, a Flask server will be started in debug mode and a ptvsd server. Otherwise, it is served using gevent production server. Default: False
24
+
25
+ ### OBJECT_STORAGE_URL
26
+
27
+ Url for the object storage. Mandatory if the code uses object storage.
28
+
29
+ ### OBJECT_STORAGE_ACCESS_KEY
30
+
31
+ Public key for the object storage.
32
+
33
+ ### OBJECT_STORAGE_SECRET_KEY
34
+
35
+ Private key for the object storage.
36
+
37
+ ### SCHEDULER_URL
38
+
39
+ Callback url of the scheduler.
40
+
41
+ ## Commands
42
+
43
+ ### Build
44
+
45
+ ```sh
46
+ docker-compose build
47
+ ```
48
+
49
+ ### Run
50
+
51
+ ```sh
52
+ docker-compose up
53
+ ```
54
+
55
+ ### Create task
56
+
57
+ You can use the tools/send_request.py script to send a simple request to the calculation container.
58
+
59
+ ### Debug
60
+
61
+ If you use Visual Studio Code, there is a debug configuration called Python: Remote Attach which will start a debug session and connect to your running container.
62
+
63
+ ## Documentation
64
+
65
+ Full HTML and PDF documentation can be generated from any revision using the generate_documentation job in the CI.
66
+ After the job have run successfully, the artifacts are stored for one day.
67
+ If it's necessary it can be rerun any time.
68
+
69
+
70
+ ......
@@ -0,0 +1,4 @@
1
+ """Version information for BlackAnt SDK"""
2
+
3
+ __version__ = "1.0.0"
4
+ __version_info__ = (1, 0, 0)
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,17 @@
1
+
2
+
3
+ # from the environment for the first two.
4
+ SPHINXOPTS ?=
5
+ SPHINXBUILD ?= sphinx-build
6
+ SOURCEDIR = source
7
+ BUILDDIR = build
8
+
9
+ help:
10
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
11
+
12
+ .PHONY: help Makefile
13
+
14
+ # Catch-all target: route all unknown targets to Sphinx using the new
15
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
16
+ %: Makefile
17
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,64 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+
3
+ import os
4
+ import sys
5
+ sys.path.insert(0, os.path.abspath('../../src'))
6
+
7
+
8
+ project = 'BlackAnt SDK'
9
+ copyright = '2025, BlackAnt Team'
10
+ author = 'BlackAnt Team'
11
+ release = '1.0.0'
12
+
13
+
14
+ extensions = [
15
+ 'sphinx.ext.autodoc',
16
+ 'sphinx.ext.napoleon',
17
+ 'sphinx.ext.viewcode',
18
+ 'sphinx.ext.todo',
19
+ 'sphinx.ext.coverage',
20
+ 'sphinx.ext.intersphinx',
21
+ ]
22
+
23
+ templates_path = ['_templates']
24
+ exclude_patterns = []
25
+
26
+ language = 'en'
27
+
28
+ # Napoleon settings for Google style docstrings
29
+ napoleon_google_docstring = True
30
+ napoleon_numpy_docstring = False
31
+ napoleon_include_init_with_doc = True
32
+ napoleon_include_private_with_doc = False
33
+ napoleon_include_special_with_doc = True
34
+ napoleon_use_admonition_for_examples = False
35
+ napoleon_use_admonition_for_notes = False
36
+ napoleon_use_admonition_for_references = False
37
+ napoleon_use_ivar = False
38
+ napoleon_use_param = True
39
+ napoleon_use_rtype = True
40
+ napoleon_preprocess_types = False
41
+ napoleon_type_aliases = None
42
+ napoleon_attr_annotations = True
43
+
44
+ # Autodoc settings
45
+ autodoc_default_options = {
46
+ 'members': True,
47
+ 'member-order': 'bysource',
48
+ 'special-members': '__init__',
49
+ 'undoc-members': True,
50
+ 'exclude-members': '__weakref__'
51
+ }
52
+
53
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
54
+
55
+ html_theme = 'sphinx_rtd_theme'
56
+ html_static_path = ['_static']
57
+
58
+ # -- Options for intersphinx extension ---------------------------------------
59
+ intersphinx_mapping = {
60
+ 'python': ('https://docs.python.org/3', None),
61
+ }
62
+
63
+ # -- Options for todo extension ----------------------------------------------
64
+ todo_include_todos = True
@@ -0,0 +1,273 @@
1
+ BlackAnt SDK Documentation
2
+ ==========================
3
+
4
+ Welcome to the BlackAnt SDK documentation. BlackAnt SDK is an enterprise-grade Python framework
5
+ for building distributed, containerized applications with comprehensive Docker integration,
6
+ secure authentication, and high-performance HTTP operations.
7
+
8
+ The SDK provides a complete toolkit for modern microservice architectures, including service
9
+ discovery, configuration management, logging, and monitoring capabilities.
10
+
11
+ .. toctree::
12
+ :maxdepth: 2
13
+ :caption: Core Modules:
14
+
15
+ modules/blackant
16
+ modules/auth
17
+ modules/docker
18
+ modules/http
19
+ modules/api
20
+ modules/services
21
+ modules/config
22
+ modules/utils
23
+ modules/patterns
24
+
25
+ Key Features
26
+ ============
27
+
28
+ **Authentication & Security**
29
+ - OAuth 2.0 / OpenID Connect integration with Keycloak
30
+ - Automatic token refresh and lifecycle management
31
+ - Thread-safe credential storage
32
+ - Admin API access for user management
33
+
34
+ **Docker Integration**
35
+ - Full Docker Engine API support
36
+ - Docker Swarm orchestration capabilities
37
+ - Container lifecycle management
38
+ - Image building and registry operations
39
+
40
+ **HTTP Client**
41
+ - High-performance HTTP client with connection pooling
42
+ - Automatic retry mechanisms with exponential backoff
43
+ - Built-in authentication token injection
44
+ - Comprehensive error handling and logging
45
+
46
+ **Service Management**
47
+ - Service discovery and registration
48
+ - Health monitoring and automatic recovery
49
+ - Namespace-based multi-tenancy
50
+ - Load balancing and traffic routing
51
+
52
+ **Configuration**
53
+ - Multi-source configuration loading (YAML, environment, CLI)
54
+ - Runtime validation and type checking
55
+ - Environment-specific profiles
56
+ - Secure credential management
57
+
58
+ Installation
59
+ ============
60
+
61
+ Install the BlackAnt SDK using pip::
62
+
63
+ pip install blackant-sdk
64
+
65
+ Or install from source::
66
+
67
+ git clone https://github.com/your-org/blackant-sdk.git
68
+ cd blackant-sdk
69
+ pip install -e .
70
+
71
+ Quick Start Guide
72
+ =================
73
+
74
+ Authentication
75
+ --------------
76
+
77
+ Authenticate with the BlackAnt platform using your credentials::
78
+
79
+ from blackant.auth.blackant_auth import BlackAntAuth
80
+
81
+ # Initialize authentication
82
+ auth = BlackAntAuth(
83
+ user="your_username",
84
+ password="your_password",
85
+ login_url="https://your-blackant-instance.com/api/auth/login"
86
+ )
87
+
88
+ # Get access token
89
+ token = auth.get_token()
90
+ print(f"Authenticated successfully: {token[:30]}...")
91
+
92
+ Docker Operations
93
+ -----------------
94
+
95
+ Manage Docker containers and services::
96
+
97
+ from blackant.docker.client import BlackAntDockerClient
98
+
99
+ # Initialize Docker client with authentication
100
+ docker_client = BlackAntDockerClient(
101
+ auth=auth,
102
+ base_url="https://your-blackant-instance.com"
103
+ )
104
+
105
+ # Get Docker information
106
+ version = docker_client.get_version()
107
+ print(f"Docker version: {version}")
108
+
109
+ # List running containers
110
+ containers = docker_client.get_containers()
111
+ print(f"Running containers: {len(containers)}")
112
+
113
+ # List available images
114
+ images = docker_client.get_images()
115
+ print(f"Available images: {len(images)}")
116
+
117
+ HTTP Client
118
+ -----------
119
+
120
+ Make authenticated HTTP requests::
121
+
122
+ from blackant.http.client import HTTPClient
123
+
124
+ # Create HTTP client with automatic authentication
125
+ http_client = HTTPClient(
126
+ base_url="https://your-api-endpoint.com",
127
+ auth=auth
128
+ )
129
+
130
+ # Make GET request
131
+ response = http_client.get("/api/data")
132
+ data = response.json()
133
+
134
+ # Make POST request
135
+ response = http_client.post("/api/create", json={"name": "example"})
136
+
137
+ Service Management
138
+ ------------------
139
+
140
+ Register and discover services::
141
+
142
+ from blackant.services.registry import ServiceRegistry
143
+
144
+ # Initialize service registry
145
+ registry = ServiceRegistry(auth=auth)
146
+
147
+ # Register a service
148
+ service_id = registry.register_service({
149
+ "name": "my-service",
150
+ "version": "1.0.0",
151
+ "health_check_url": "/health"
152
+ })
153
+
154
+ # Discover services
155
+ services = registry.discover_services("my-service")
156
+
157
+ Configuration Management
158
+ ------------------------
159
+
160
+ Load and manage configuration::
161
+
162
+ from blackant.config.manager import ConfigManager
163
+
164
+ # Initialize configuration
165
+ config = ConfigManager()
166
+ config.load_from_yaml("config.yaml")
167
+ config.load_from_environment()
168
+
169
+ # Access configuration values
170
+ database_url = config.get("database.url")
171
+ api_timeout = config.get("api.timeout", default=30)
172
+
173
+ Architecture Overview
174
+ =====================
175
+
176
+ The BlackAnt SDK follows a modular architecture with clear separation of concerns:
177
+
178
+ **Core Layer**
179
+ - Authentication and authorization (``blackant.auth``)
180
+ - Configuration management (``blackant.config``)
181
+ - Utilities and helpers (``blackant.utils``)
182
+
183
+ **Integration Layer**
184
+ - Docker operations (``blackant.docker``)
185
+ - HTTP client (``blackant.http``)
186
+ - API client (``blackant.api``)
187
+
188
+ **Service Layer**
189
+ - Service discovery and management (``blackant.services``)
190
+ - Design patterns and best practices (``blackant.patterns``)
191
+
192
+ Error Handling
193
+ ==============
194
+
195
+ The SDK provides comprehensive error handling with specific exception types::
196
+
197
+ from blackant.exceptions import BlackAntAuthenticationError, BlackAntDockerError
198
+
199
+ try:
200
+ auth.authenticate()
201
+ except BlackAntAuthenticationError as e:
202
+ print(f"Authentication failed: {e}")
203
+
204
+ try:
205
+ docker_client.get_containers()
206
+ except BlackAntDockerError as e:
207
+ print(f"Docker operation failed: {e}")
208
+
209
+ Logging
210
+ =======
211
+
212
+ Enable comprehensive logging for debugging and monitoring::
213
+
214
+ from blackant.utils.logging import init_logging, get_logger
215
+
216
+ # Initialize logging with custom settings
217
+ init_logging(
218
+ app_name="MyApp",
219
+ log_level="DEBUG",
220
+ enable_colors=True,
221
+ enable_request_tracking=True
222
+ )
223
+
224
+ # Get logger for your module
225
+ logger = get_logger("my_module")
226
+ logger.info("Application started")
227
+
228
+ Best Practices
229
+ ==============
230
+
231
+ **Security**
232
+ - Always use environment variables for sensitive credentials
233
+ - Enable request ID tracking for audit trails
234
+ - Use the built-in sensitive data filtering in logs
235
+
236
+ **Performance**
237
+ - Reuse HTTP client instances to benefit from connection pooling
238
+ - Configure appropriate timeout values for your environment
239
+ - Use caching for frequently accessed configuration values
240
+
241
+ **Reliability**
242
+ - Implement proper error handling and retry logic
243
+ - Monitor service health and implement circuit breakers
244
+ - Use structured logging for better observability
245
+
246
+ API Reference
247
+ =============
248
+
249
+ For detailed API documentation, see the module reference pages linked in the table of contents.
250
+ Each module provides comprehensive documentation of classes, methods, and usage examples.
251
+
252
+ Contributing
253
+ ============
254
+
255
+ Contributions are welcome! Please see the project repository for contribution guidelines
256
+ and development setup instructions.
257
+
258
+ Support
259
+ =======
260
+
261
+ For support and questions:
262
+
263
+ - Documentation: This site
264
+ - Issues: GitHub Issues
265
+
266
+
267
+ Indices and Tables
268
+ ==================
269
+
270
+ * :ref:`genindex`
271
+ * :ref:`modindex`
272
+ * :ref:`search`
273
+
@@ -0,0 +1,56 @@
1
+ API Module
2
+ ==========
3
+
4
+ The BlackAnt API module provides a comprehensive REST API client with automatic
5
+ versioning, endpoint discovery, and response processing. It offers both high-level
6
+ convenience methods and low-level API access for maximum flexibility.
7
+
8
+ Features include:
9
+
10
+ * Automatic API versioning and endpoint resolution
11
+ * Type-safe request/response handling with validation
12
+ * Comprehensive error handling and retry logic
13
+ * Built-in authentication and authorization
14
+ * Request/response interceptors and middleware support
15
+ * Real-time API monitoring and performance metrics
16
+ * OpenAPI specification integration and validation
17
+
18
+ API Client
19
+ ----------
20
+
21
+ High-level API client with automatic authentication and error handling.
22
+
23
+ .. automodule:: blackant.api.client
24
+ :members:
25
+ :undoc-members:
26
+ :show-inheritance:
27
+
28
+ Endpoint Management
29
+ -------------------
30
+
31
+ Dynamic endpoint discovery and URL construction with versioning support.
32
+
33
+ .. automodule:: blackant.api.endpoints
34
+ :members:
35
+ :undoc-members:
36
+ :show-inheritance:
37
+
38
+ API Versioning
39
+ --------------
40
+
41
+ Automatic API version detection and compatibility management.
42
+
43
+ .. automodule:: blackant.api.versioning
44
+ :members:
45
+ :undoc-members:
46
+ :show-inheritance:
47
+
48
+ API Exceptions
49
+ --------------
50
+
51
+ Specialized exception handling for API-specific error conditions.
52
+
53
+ .. automodule:: blackant.api.exceptions
54
+ :members:
55
+ :undoc-members:
56
+ :show-inheritance: