axmp-openapi-helper 0.1.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.
Files changed (29) hide show
  1. axmp_openapi_helper-0.1.0/.cursorrules +9 -0
  2. axmp_openapi_helper-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  3. axmp_openapi_helper-0.1.0/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  4. axmp_openapi_helper-0.1.0/.github/ISSUE_TEMPLATE/release-template.md +10 -0
  5. axmp_openapi_helper-0.1.0/.gitignore +174 -0
  6. axmp_openapi_helper-0.1.0/.pre-commit-config.yaml +24 -0
  7. axmp_openapi_helper-0.1.0/.python-version +1 -0
  8. axmp_openapi_helper-0.1.0/LICENSE +21 -0
  9. axmp_openapi_helper-0.1.0/PKG-INFO +299 -0
  10. axmp_openapi_helper-0.1.0/README.md +282 -0
  11. axmp_openapi_helper-0.1.0/logging.conf +40 -0
  12. axmp_openapi_helper-0.1.0/poetry.lock +807 -0
  13. axmp_openapi_helper-0.1.0/pyproject.toml +81 -0
  14. axmp_openapi_helper-0.1.0/pyproject.toml.poetry +83 -0
  15. axmp_openapi_helper-0.1.0/runner/multi_openapi_helper_runner.py +103 -0
  16. axmp_openapi_helper-0.1.0/runner/openapi/zcp/zcp_alert_backend_openapi_spec.json +6314 -0
  17. axmp_openapi_helper-0.1.0/runner/openapi/zcp/zcp_mcm_backend_openapi_spec.json +28440 -0
  18. axmp_openapi_helper-0.1.0/runner/openapi/zcp/zcp_monitoring_backend_openapi_spec.json +6249 -0
  19. axmp_openapi_helper-0.1.0/runner/openapi/zmp_multi_openapi_spec.json +50 -0
  20. axmp_openapi_helper-0.1.0/runner/openapi/zmp_multi_openapi_spec2.json +180 -0
  21. axmp_openapi_helper-0.1.0/src/axmp_openapi_helper/__init__.py +14 -0
  22. axmp_openapi_helper-0.1.0/src/axmp_openapi_helper/multi_openapi_helper.py +629 -0
  23. axmp_openapi_helper-0.1.0/src/axmp_openapi_helper/openapi/axmp_api_models.py +873 -0
  24. axmp_openapi_helper-0.1.0/src/axmp_openapi_helper/openapi/fastapi/openapi_models.py +400 -0
  25. axmp_openapi_helper-0.1.0/src/axmp_openapi_helper/openapi/multi_openapi_spec.py +186 -0
  26. axmp_openapi_helper-0.1.0/src/axmp_openapi_helper/openapi/operation.py +48 -0
  27. axmp_openapi_helper-0.1.0/src/axmp_openapi_helper/wrapper/api_wrapper.py +250 -0
  28. axmp_openapi_helper-0.1.0/tests/__init__.py +0 -0
  29. axmp_openapi_helper-0.1.0/uv.lock +530 -0
@@ -0,0 +1,9 @@
1
+ # docstring
2
+ all docstring should be in english
3
+
4
+ # test code
5
+ all test code should be written by pytest
6
+ all fixture should be located in the conftest.py
7
+
8
+ # lint and formatting
9
+ should use ruff for linting and formatting
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: "[Bug]"
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+ - OS: [e.g. iOS]
28
+ - Browser [e.g. chrome, safari]
29
+ - Version [e.g. 22]
30
+
31
+ **Smartphone (please complete the following information):**
32
+ - Device: [e.g. iPhone6]
33
+ - OS: [e.g. iOS8.1]
34
+ - Browser [e.g. stock browser, safari]
35
+ - Version [e.g. 22]
36
+
37
+ **Additional context**
38
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: "[Feature]"
5
+ labels: enhancement
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: Release template
3
+ about: This is a Release Task template
4
+ title: "[Release]"
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+
@@ -0,0 +1,174 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # Ruff stuff:
171
+ .ruff_cache/
172
+
173
+ # PyPI configuration file
174
+ .pypirc
@@ -0,0 +1,24 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ args: [--markdown-linebreak-ext=md]
7
+ - id: end-of-file-fixer
8
+ exclude: \.(md|drawio)$
9
+ - id: debug-statements
10
+
11
+
12
+ - repo: https://github.com/astral-sh/ruff-pre-commit
13
+ # Ruff version.
14
+ rev: v0.9.10
15
+ hooks:
16
+ # Run the linter.
17
+ - id: ruff
18
+ args: [ --fix ]
19
+ types_or: [python]
20
+ exclude: \.(md|drawio)$
21
+ # Run the formatter.
22
+ - id: ruff-format
23
+ types_or: [python]
24
+ exclude: \.(md|drawio)$
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Cloud Z MP
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,299 @@
1
+ Metadata-Version: 2.4
2
+ Name: axmp-openapi-helper
3
+ Version: 0.1.0
4
+ Summary: This is a openapi helper library for the ZMP AI Platform
5
+ Project-URL: homepage, https://github.com/cloudz-mp
6
+ Project-URL: repository, https://github.com/cloudz-mp/axmp-openapi-helper
7
+ Project-URL: documentation, https://github.com/cloudz-mp/axmp-openapi-helper
8
+ Project-URL: Bug Tracker, https://github.com/cloudz-mp/axmp-openapi-helper/issues
9
+ Author-email: Kilsoo Kang <kilsoo75@gmail.com>
10
+ License-File: LICENSE
11
+ Requires-Python: <4.0,>=3.12
12
+ Requires-Dist: colorlog>=6.9.0
13
+ Requires-Dist: httpx>=0.28.1
14
+ Requires-Dist: pydantic>=2.11.7
15
+ Requires-Dist: python-dotenv>=1.1.1
16
+ Description-Content-Type: text/markdown
17
+
18
+ # axmp-openapi-helper
19
+
20
+ ![Platform Badge](https://img.shields.io/badge/platform-zmp-red)
21
+ ![Component Badge](https://img.shields.io/badge/component-openapi_helper-red)
22
+ ![CI Badge](https://img.shields.io/badge/ci-github_action-green)
23
+ ![License Badge](https://img.shields.io/badge/license-MIT-green)
24
+ ![PyPI - Version](https://img.shields.io/pypi/v/axmp-openapi-helper)
25
+ ![PyPI - Implementation](https://img.shields.io/pypi/implementation/axmp-openapi-helper)
26
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/axmp-openapi-helper)
27
+ ![PyPI - Wheel](https://img.shields.io/pypi/wheel/axmp-openapi-helper)
28
+ ![PyPI - Download](https://img.shields.io/pypi/dm/axmp-openapi-helper)
29
+
30
+ ## Introduction
31
+
32
+ This is a openapi helper library for the ZMP AI Platform
33
+
34
+ ## Key Features
35
+
36
+ - Support the OpenAPI Specification(>=3.0.0)
37
+ - Generate the Arguments Schema for the LLM
38
+
39
+ ## Installation
40
+
41
+ Install using pip:
42
+
43
+ ```bash
44
+ pip install axmp-openapi-helper
45
+ ```
46
+
47
+ Install using poetry:
48
+ ```bash
49
+ poetry add axmp-openapi-helper
50
+ ```
51
+
52
+ ## Usage
53
+
54
+ Basic example:
55
+
56
+ ```python
57
+ import logging
58
+ import logging.config
59
+
60
+ from axmp_openapi_helper import (
61
+ MixedAPISpecConfig,
62
+ ZmpAPIWrapper,
63
+ )
64
+
65
+ logging.config.fileConfig("logging.conf", disable_existing_loggers=False)
66
+ logging.getLogger("axmp_openapi_helper.openapi.zmpapi_models").setLevel(logging.INFO)
67
+ logging.getLogger("axmp_openapi_helper.toolkits.toolkit").setLevel(logging.INFO)
68
+ logger = logging.getLogger("appLogger")
69
+ logger.setLevel(logging.DEBUG)
70
+
71
+ if __name__ == "__main__":
72
+ mixed_api_spec_config = MixedAPISpecConfig.from_mixed_spec_file(
73
+ file_path="runner/openapi/zmp_mixed_api_spec.json"
74
+ )
75
+
76
+ zmp_api_wrapper = ZmpAPIWrapper(
77
+ "https://api.test.company.com",
78
+ mixed_api_spec_config=mixed_api_spec_config,
79
+ auth_type=AuthenticationType.CUSTOM,
80
+ custom_auth_header_key="X-Access-Key",
81
+ custom_auth_header_value="xxxxx",
82
+ )
83
+
84
+ operations = zmp_api_wrapper.get_operations()
85
+ for operation in operations:
86
+ print("-" * 100)
87
+ print(operation.args_schema)
88
+ for field_name, field_info in operation.args_schema.model_fields.items():
89
+ print(
90
+ f"\t{field_name}: {field_info.annotation}, {field_info.default}, {field_info.description}"
91
+ )
92
+
93
+ response = zmp_api_wrapper.run(
94
+ "GET",
95
+ "/api/alert/v1/alerts",
96
+ query_params=None
97
+ )
98
+ print(response)
99
+ ```
100
+
101
+ Mixed API Spec Config Sample
102
+
103
+ ```json
104
+ {
105
+ "backends": [
106
+ {
107
+ "backend": "zcp-alert-backend",
108
+ "config": {
109
+ "file_path": "runner/openapi/zcp/zcp_alert_backend_openapi_spec.json",
110
+ "prefix": "/api/alert/v1",
111
+ "apis": [
112
+ {
113
+ "path":"/api/alert/v1/alerts",
114
+ "methods": ["get"]
115
+ },
116
+ {
117
+ "path":"/api/alert/v1/alerts",
118
+ "methods": ["post"]
119
+ },
120
+ {
121
+ "path":"/api/alert/v1/alerts/{alert_id}",
122
+ "methods": ["get"]
123
+ },
124
+ {
125
+ "path":"/api/alert/v1/alerts/webhook",
126
+ "methods": ["post"]
127
+ },
128
+ {
129
+ "path":"/api/alert/v1/alerts/{alert_id}/{action}",
130
+ "methods": ["patch"]
131
+ },
132
+ {
133
+ "path":"/api/alert/v1/alerts/bulk/{action}",
134
+ "methods": [
135
+ {
136
+ "method": "patch",
137
+ "description": "Bulk action on alerts"
138
+ }
139
+ ]
140
+ }
141
+ ]
142
+ }
143
+ },
144
+ {
145
+ "backend": "zcp-mcm-backend",
146
+ "config": {
147
+ "file_path": "runner/openapi/zcp/zcp_mcm_backend_openapi_spec.json",
148
+ "prefix": "/api/mcm/resource/v1beta1",
149
+ "apis": [
150
+ {
151
+ "path":"/api/mcm/resource/v1beta1/workload/pods",
152
+ "methods": [
153
+ {
154
+ "method": "get",
155
+ "description": "Get pods using the query parameters"
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ "path":"/api/mcm/resource/v1beta1/workload/pods/{name}",
161
+ "methods": [
162
+ {
163
+ "method": "get",
164
+ "description": "Get pod details by name and cluster and namespace parameters"
165
+ }
166
+ ]
167
+ },
168
+ {
169
+ "path":"/api/mcm/resource/v1beta1/workload/pods/events",
170
+ "methods": [
171
+ {
172
+ "method": "get",
173
+ "description": "Get pod events by id which is consists of cluster, namespace and pod name. seperated by $. e.g.)id=cluster1$namespace1$pod1"
174
+ }
175
+ ]
176
+ },
177
+ {
178
+ "path":"/api/mcm/resource/v1beta1/workload/pods/metrics",
179
+ "methods": [
180
+ {
181
+ "method": "get",
182
+ "description": "Get pod metrics by id which is consists of cluster, namespace and pod name. seperated by $. e.g.)id=cluster1$namespace1$pod1"
183
+ }
184
+ ]
185
+ },
186
+ {
187
+ "path":"/api/mcm/resource/v1beta1/accesscontrol/clusterrolebindings",
188
+ "methods": ["get", "delete"]
189
+ },
190
+ {
191
+ "path":"/api/mcm/resource/v1beta1/clusters",
192
+ "methods": [
193
+ {
194
+ "method": "get",
195
+ "description": "Get clusters using the query parameters"
196
+ }
197
+ ]
198
+ }
199
+ ]
200
+ }
201
+ },
202
+ {
203
+ "backend": "zcp-monitoring-backend",
204
+ "config": {
205
+ "file_path": "runner/openapi/zcp/zcp_monitoring_backend_openapi_spec.json",
206
+ "prefix": "/api/monitoring/v1beta1",
207
+ "apis": [
208
+ {
209
+ "path":"/api/monitoring/v1beta1/realms/{realm}/rules/{namespace}",
210
+ "methods": [
211
+ {
212
+ "method": "get",
213
+ "description": "Get rule groups by realm and namespace"
214
+ }
215
+ ]
216
+ },
217
+ {
218
+ "path":"/api/monitoring/v1beta1/realms/{realm}/events",
219
+ "methods": [
220
+ {
221
+ "method": "get",
222
+ "description": "Get events by realm"
223
+ }
224
+ ]
225
+ },
226
+ {
227
+ "path":"/api/monitoring/v1beta1/realms/{realm}/metrics/clusters",
228
+ "methods": [
229
+ {
230
+ "method": "get",
231
+ "description": "Get metrics of clusters by realm"
232
+ }
233
+ ]
234
+ },
235
+ {
236
+ "path":"/api/monitoring/v1beta1/realms/{realm}/metrics/nodes",
237
+ "methods": [
238
+ {
239
+ "method": "get",
240
+ "description": "Get metrics of nodes by realm"
241
+ }
242
+ ]
243
+ },
244
+ {
245
+ "path":"/api/monitoring/v1beta1/realms/{realm}/metrics/pods",
246
+ "methods": [
247
+ {
248
+ "method": "get",
249
+ "tool_name": "get_metrics_of_pods_by_realm",
250
+ "description": "Get metrics of pods by realm"
251
+ }
252
+ ]
253
+ }
254
+ ]
255
+ }
256
+ }
257
+ ]
258
+ }
259
+ ```
260
+
261
+ For more detailed usage instructions, please refer to our [documentation](link).
262
+
263
+ ## Development Setup
264
+
265
+ 1. Clone the repository
266
+ ```bash
267
+ git clone https://github.com/yourusername/axmp-openapi-helper.git
268
+ cd axmp-openapi-helper
269
+ ```
270
+
271
+ 2. Create and activate virtual environment
272
+ ```bash
273
+ python -m venv .venv
274
+ source .venv/bin/activate # Windows: venv\Scripts\activate
275
+ ```
276
+
277
+ 3. Install development dependencies
278
+ ```bash
279
+ poetry install
280
+ ```
281
+
282
+ ## Contributing
283
+
284
+ 1. Fork the repository
285
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
286
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
287
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
288
+ 5. Open a Pull Request
289
+
290
+ ## License
291
+
292
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
293
+
294
+ ## Contact
295
+
296
+ - Issue Tracker: https://github.com/cloudz-mp/axmp-openapi-helper/issues
297
+ - Email: kilsoo75@gmail.com
298
+
299
+