py-acs-sdk 1.0.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 (84) hide show
  1. py_acs_sdk-1.0.0/PKG-INFO +187 -0
  2. py_acs_sdk-1.0.0/README.md +170 -0
  3. py_acs_sdk-1.0.0/pyproject.toml +52 -0
  4. py_acs_sdk-1.0.0/setup.cfg +4 -0
  5. py_acs_sdk-1.0.0/setup.py +18 -0
  6. py_acs_sdk-1.0.0/src/acs_sdk/__init__.py +26 -0
  7. py_acs_sdk-1.0.0/src/acs_sdk/acs.py +136 -0
  8. py_acs_sdk-1.0.0/src/acs_sdk/cli.py +51 -0
  9. py_acs_sdk-1.0.0/src/acs_sdk/client/__init__.py +0 -0
  10. py_acs_sdk-1.0.0/src/acs_sdk/client/client.py +330 -0
  11. py_acs_sdk-1.0.0/src/acs_sdk/client/contract.py +26 -0
  12. py_acs_sdk-1.0.0/src/acs_sdk/commands/__init__.py +0 -0
  13. py_acs_sdk-1.0.0/src/acs_sdk/commands/region.py +31 -0
  14. py_acs_sdk-1.0.0/src/acs_sdk/commands/service_offering.py +42 -0
  15. py_acs_sdk-1.0.0/src/acs_sdk/commands/vm.py +42 -0
  16. py_acs_sdk-1.0.0/src/acs_sdk/commands/volume.py +32 -0
  17. py_acs_sdk-1.0.0/src/acs_sdk/commands/zone.py +31 -0
  18. py_acs_sdk-1.0.0/src/acs_sdk/core/__init__.py +0 -0
  19. py_acs_sdk-1.0.0/src/acs_sdk/core/response_mapper.py +29 -0
  20. py_acs_sdk-1.0.0/src/acs_sdk/core/retry.py +71 -0
  21. py_acs_sdk-1.0.0/src/acs_sdk/core/signer.py +67 -0
  22. py_acs_sdk-1.0.0/src/acs_sdk/core/timer.py +48 -0
  23. py_acs_sdk-1.0.0/src/acs_sdk/decorators/__init__.py +0 -0
  24. py_acs_sdk-1.0.0/src/acs_sdk/exceptions/__init__.py +23 -0
  25. py_acs_sdk-1.0.0/src/acs_sdk/schemas/__init__.py +0 -0
  26. py_acs_sdk-1.0.0/src/acs_sdk/schemas/config.py +62 -0
  27. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/__init__.py +0 -0
  28. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/account.py +165 -0
  29. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/address.py +198 -0
  30. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/backup_and_recovery.py +122 -0
  31. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/base.py +12 -0
  32. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/disk_offering.py +80 -0
  33. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/firewall.py +406 -0
  34. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/job.py +41 -0
  35. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/nat.py +76 -0
  36. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/network.py +622 -0
  37. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/network_acl.py +345 -0
  38. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/network_offering.py +93 -0
  39. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/region.py +11 -0
  40. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/security_group.py +138 -0
  41. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/service_offering.py +113 -0
  42. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/snapshot.py +115 -0
  43. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/ssh.py +71 -0
  44. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/template.py +115 -0
  45. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/usage.py +93 -0
  46. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/virtual_machine.py +323 -0
  47. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/volume.py +604 -0
  48. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/vpc.py +293 -0
  49. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/vpc_offering.py +30 -0
  50. py_acs_sdk-1.0.0/src/acs_sdk/schemas/request/zone.py +33 -0
  51. py_acs_sdk-1.0.0/src/acs_sdk/schemas/response/__init__.py +0 -0
  52. py_acs_sdk-1.0.0/src/acs_sdk/schemas/response/base.py +69 -0
  53. py_acs_sdk-1.0.0/src/acs_sdk/services/__init__.py +0 -0
  54. py_acs_sdk-1.0.0/src/acs_sdk/services/account.py +175 -0
  55. py_acs_sdk-1.0.0/src/acs_sdk/services/address.py +166 -0
  56. py_acs_sdk-1.0.0/src/acs_sdk/services/backup_and_recovery.py +332 -0
  57. py_acs_sdk-1.0.0/src/acs_sdk/services/base.py +146 -0
  58. py_acs_sdk-1.0.0/src/acs_sdk/services/disk_offering.py +27 -0
  59. py_acs_sdk-1.0.0/src/acs_sdk/services/firewall.py +432 -0
  60. py_acs_sdk-1.0.0/src/acs_sdk/services/job.py +164 -0
  61. py_acs_sdk-1.0.0/src/acs_sdk/services/nat.py +109 -0
  62. py_acs_sdk-1.0.0/src/acs_sdk/services/network.py +1212 -0
  63. py_acs_sdk-1.0.0/src/acs_sdk/services/network_acl.py +210 -0
  64. py_acs_sdk-1.0.0/src/acs_sdk/services/network_offering.py +27 -0
  65. py_acs_sdk-1.0.0/src/acs_sdk/services/region.py +25 -0
  66. py_acs_sdk-1.0.0/src/acs_sdk/services/security_group.py +156 -0
  67. py_acs_sdk-1.0.0/src/acs_sdk/services/service_offering.py +27 -0
  68. py_acs_sdk-1.0.0/src/acs_sdk/services/snapshot.py +209 -0
  69. py_acs_sdk-1.0.0/src/acs_sdk/services/ssh.py +90 -0
  70. py_acs_sdk-1.0.0/src/acs_sdk/services/template.py +29 -0
  71. py_acs_sdk-1.0.0/src/acs_sdk/services/usage.py +80 -0
  72. py_acs_sdk-1.0.0/src/acs_sdk/services/virtual_machine.py +226 -0
  73. py_acs_sdk-1.0.0/src/acs_sdk/services/volume.py +446 -0
  74. py_acs_sdk-1.0.0/src/acs_sdk/services/vpc.py +232 -0
  75. py_acs_sdk-1.0.0/src/acs_sdk/services/vpc_offering.py +27 -0
  76. py_acs_sdk-1.0.0/src/acs_sdk/services/zone.py +24 -0
  77. py_acs_sdk-1.0.0/src/acs_sdk/utils/__init__.py +0 -0
  78. py_acs_sdk-1.0.0/src/acs_sdk/utils/ipaddress.py +47 -0
  79. py_acs_sdk-1.0.0/src/py_acs_sdk.egg-info/PKG-INFO +187 -0
  80. py_acs_sdk-1.0.0/src/py_acs_sdk.egg-info/SOURCES.txt +82 -0
  81. py_acs_sdk-1.0.0/src/py_acs_sdk.egg-info/dependency_links.txt +1 -0
  82. py_acs_sdk-1.0.0/src/py_acs_sdk.egg-info/entry_points.txt +2 -0
  83. py_acs_sdk-1.0.0/src/py_acs_sdk.egg-info/requires.txt +4 -0
  84. py_acs_sdk-1.0.0/src/py_acs_sdk.egg-info/top_level.txt +1 -0
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: py-acs-sdk
3
+ Version: 1.0.0
4
+ Summary: Python SDK for Apache CloudStack API
5
+ Home-page: https://github.com
6
+ Author: Vimal Kumar Saini
7
+ Author-email: Vimal Saini <vimal.saini25@gmail.com>
8
+ License: MIT
9
+ Requires-Python: >=3.12
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: httpx<0.29.0,>=0.28.1
12
+ Requires-Dist: pydantic<3.0.0,>=2.12.5
13
+ Requires-Dist: click<9.0.0,>=8.3.1
14
+ Requires-Dist: opentelemetry-sdk<2.0.0,>=1.40.0
15
+ Dynamic: author
16
+ Dynamic: home-page
17
+
18
+ # Apache CloudStack Python SDK
19
+
20
+ A Python SDK for the Apache CloudStack API that provides a simple and type-safe interface to manage resources.
21
+
22
+ ## Features
23
+
24
+ - 🔐 **Type-Safe** - Built with Pydantic for request/response validation
25
+ - 🚀 **Async Support** - Built on httpx for modern async HTTP requests
26
+ - 📦 **Easy Configuration** - Simple configuration management
27
+ - 🧪 **Well Tested** - Comprehensive test suite with pytest
28
+ - 🔄 **Automatic Retry** - Built-in retry logic with exponential backoff
29
+ - 🔑 **Request Signing** - Automatic HMAC-SHA1 request signing
30
+ - 💻 **CLI Tool** - Command-line interface for quick operations
31
+
32
+ ## Requirements
33
+
34
+ - Python >= 3.12
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install acs-sdk
40
+ ```
41
+
42
+ ## Getting Started
43
+
44
+ ### Basic Setup
45
+
46
+ ```python
47
+ from acs_sdk import ApacheCloudStackClient, ApacheCloudStackConfig
48
+
49
+ # Create a configuration
50
+ config = ApacheCloudStackConfig(
51
+ endpoint="https://your-cloudstack-endpoint/api",
52
+ api_key="your_api_key",
53
+ api_secret="your_api_secret"
54
+ )
55
+
56
+ # Initialize the CloudStack client
57
+ client = ApacheCloudStackClient(config)
58
+ ```
59
+
60
+ ### Making API Calls
61
+
62
+ ```python
63
+ # List users
64
+ response = client.call('listUsers')
65
+
66
+ # Get user with parameters
67
+ user_response = client.call('getUser', {'userid': '123'})
68
+
69
+ # Don't forget to close the client
70
+ client.close()
71
+ ```
72
+
73
+ ### Async API Calls
74
+
75
+ ```python
76
+ import asyncio
77
+ from acs_sdk import ApacheCloudStackAsyncClient, ApacheCloudStackConfig
78
+
79
+ async def main():
80
+ config = ApacheCloudStackConfig(
81
+ endpoint="https://your-cloudstack-endpoint/api",
82
+ api_key="your_api_key",
83
+ api_secret="your_api_secret"
84
+ )
85
+
86
+ async with ApacheCloudStackAsyncClient(config) as client:
87
+ response = await client.call_async('listUsers')
88
+ print(response)
89
+
90
+ asyncio.run(main())
91
+ ```
92
+
93
+ ## Command-Line Interface (CLI)
94
+
95
+ The SDK includes a CLI tool for quick operations without writing code.
96
+
97
+ ### Setup Environment Variables
98
+
99
+ ```bash
100
+ export CLOUDSTACK_ENDPOINT="https://your-cloudstack-endpoint/api"
101
+ export CLOUDSTACK_API_KEY="your_api_key"
102
+ export CLOUDSTACK_API_SECRET="your_api_secret"
103
+ ```
104
+
105
+ ### Available Commands
106
+
107
+ ```bash
108
+ # List all regions
109
+ acs list-regions
110
+
111
+ # List all users
112
+ acs list-users
113
+
114
+ # View help
115
+ acs --help
116
+ acs list-regions --help
117
+ ```
118
+
119
+ ### CLI Options
120
+
121
+ You can also provide options directly:
122
+
123
+ ```bash
124
+ acs --endpoint "https://..." --api-key "..." --api-secret "..." list-regions
125
+ ```
126
+
127
+ ## Project Structure
128
+
129
+ ```
130
+ src/
131
+ ├── acs_sdk/
132
+ │ ├── client/ # HTTP client implementation
133
+ │ ├── core/ # Retry logic and request signing
134
+ │ ├── schemas/ # Configuration schemas
135
+ │ ├── exceptions/ # Custom exceptions
136
+ │ └── cli.py # Command-line interface
137
+ tests/
138
+ ├── unit/ # Unit tests
139
+ └── conftest.py # Pytest configuration
140
+ ```
141
+
142
+ ## Development
143
+
144
+ ### Setup Development Environment
145
+
146
+ ```bash
147
+ # Create virtual environment
148
+ python -m venv .venv
149
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
150
+
151
+ # Install dependencies with dev tools
152
+ pip install -e ".[dev]"
153
+ ```
154
+
155
+ ### Running Tests
156
+
157
+ ```bash
158
+ # Run all tests with coverage
159
+ pytest
160
+
161
+ # Run specific test file
162
+ pytest tests/unit/test_client.py
163
+
164
+ # Run with coverage report
165
+ pytest --cov=acs_sdk --cov-report=html
166
+ ```
167
+
168
+ ### Code Structure
169
+
170
+ - **Client** - Handles HTTP requests to Apache CloudStack API
171
+ - **Core** - Retry logic and request signing utilities
172
+ - **Schemas** - Pydantic models for configuration validation
173
+ - **CLI** - Command-line interface for CloudStack operations
174
+
175
+ ## Dependencies
176
+
177
+ - **httpx** (>=0.28.1) - Modern HTTP client for async support
178
+ - **pydantic** (>=2.12.5) - Data validation and serialization
179
+ - **click** (>=8.3.1) - Command-line interface creation
180
+
181
+ ## License
182
+
183
+ MIT
184
+
185
+ ## Author
186
+
187
+ Vimal Saini - vimal.saini25@gmail.com
@@ -0,0 +1,170 @@
1
+ # Apache CloudStack Python SDK
2
+
3
+ A Python SDK for the Apache CloudStack API that provides a simple and type-safe interface to manage resources.
4
+
5
+ ## Features
6
+
7
+ - 🔐 **Type-Safe** - Built with Pydantic for request/response validation
8
+ - 🚀 **Async Support** - Built on httpx for modern async HTTP requests
9
+ - 📦 **Easy Configuration** - Simple configuration management
10
+ - 🧪 **Well Tested** - Comprehensive test suite with pytest
11
+ - 🔄 **Automatic Retry** - Built-in retry logic with exponential backoff
12
+ - 🔑 **Request Signing** - Automatic HMAC-SHA1 request signing
13
+ - 💻 **CLI Tool** - Command-line interface for quick operations
14
+
15
+ ## Requirements
16
+
17
+ - Python >= 3.12
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install acs-sdk
23
+ ```
24
+
25
+ ## Getting Started
26
+
27
+ ### Basic Setup
28
+
29
+ ```python
30
+ from acs_sdk import ApacheCloudStackClient, ApacheCloudStackConfig
31
+
32
+ # Create a configuration
33
+ config = ApacheCloudStackConfig(
34
+ endpoint="https://your-cloudstack-endpoint/api",
35
+ api_key="your_api_key",
36
+ api_secret="your_api_secret"
37
+ )
38
+
39
+ # Initialize the CloudStack client
40
+ client = ApacheCloudStackClient(config)
41
+ ```
42
+
43
+ ### Making API Calls
44
+
45
+ ```python
46
+ # List users
47
+ response = client.call('listUsers')
48
+
49
+ # Get user with parameters
50
+ user_response = client.call('getUser', {'userid': '123'})
51
+
52
+ # Don't forget to close the client
53
+ client.close()
54
+ ```
55
+
56
+ ### Async API Calls
57
+
58
+ ```python
59
+ import asyncio
60
+ from acs_sdk import ApacheCloudStackAsyncClient, ApacheCloudStackConfig
61
+
62
+ async def main():
63
+ config = ApacheCloudStackConfig(
64
+ endpoint="https://your-cloudstack-endpoint/api",
65
+ api_key="your_api_key",
66
+ api_secret="your_api_secret"
67
+ )
68
+
69
+ async with ApacheCloudStackAsyncClient(config) as client:
70
+ response = await client.call_async('listUsers')
71
+ print(response)
72
+
73
+ asyncio.run(main())
74
+ ```
75
+
76
+ ## Command-Line Interface (CLI)
77
+
78
+ The SDK includes a CLI tool for quick operations without writing code.
79
+
80
+ ### Setup Environment Variables
81
+
82
+ ```bash
83
+ export CLOUDSTACK_ENDPOINT="https://your-cloudstack-endpoint/api"
84
+ export CLOUDSTACK_API_KEY="your_api_key"
85
+ export CLOUDSTACK_API_SECRET="your_api_secret"
86
+ ```
87
+
88
+ ### Available Commands
89
+
90
+ ```bash
91
+ # List all regions
92
+ acs list-regions
93
+
94
+ # List all users
95
+ acs list-users
96
+
97
+ # View help
98
+ acs --help
99
+ acs list-regions --help
100
+ ```
101
+
102
+ ### CLI Options
103
+
104
+ You can also provide options directly:
105
+
106
+ ```bash
107
+ acs --endpoint "https://..." --api-key "..." --api-secret "..." list-regions
108
+ ```
109
+
110
+ ## Project Structure
111
+
112
+ ```
113
+ src/
114
+ ├── acs_sdk/
115
+ │ ├── client/ # HTTP client implementation
116
+ │ ├── core/ # Retry logic and request signing
117
+ │ ├── schemas/ # Configuration schemas
118
+ │ ├── exceptions/ # Custom exceptions
119
+ │ └── cli.py # Command-line interface
120
+ tests/
121
+ ├── unit/ # Unit tests
122
+ └── conftest.py # Pytest configuration
123
+ ```
124
+
125
+ ## Development
126
+
127
+ ### Setup Development Environment
128
+
129
+ ```bash
130
+ # Create virtual environment
131
+ python -m venv .venv
132
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
133
+
134
+ # Install dependencies with dev tools
135
+ pip install -e ".[dev]"
136
+ ```
137
+
138
+ ### Running Tests
139
+
140
+ ```bash
141
+ # Run all tests with coverage
142
+ pytest
143
+
144
+ # Run specific test file
145
+ pytest tests/unit/test_client.py
146
+
147
+ # Run with coverage report
148
+ pytest --cov=acs_sdk --cov-report=html
149
+ ```
150
+
151
+ ### Code Structure
152
+
153
+ - **Client** - Handles HTTP requests to Apache CloudStack API
154
+ - **Core** - Retry logic and request signing utilities
155
+ - **Schemas** - Pydantic models for configuration validation
156
+ - **CLI** - Command-line interface for CloudStack operations
157
+
158
+ ## Dependencies
159
+
160
+ - **httpx** (>=0.28.1) - Modern HTTP client for async support
161
+ - **pydantic** (>=2.12.5) - Data validation and serialization
162
+ - **click** (>=8.3.1) - Command-line interface creation
163
+
164
+ ## License
165
+
166
+ MIT
167
+
168
+ ## Author
169
+
170
+ Vimal Saini - vimal.saini25@gmail.com
@@ -0,0 +1,52 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "py-acs-sdk"
7
+ version = "1.0.0"
8
+ description = "Python SDK for Apache CloudStack API"
9
+ authors = [
10
+ {name = "Vimal Saini",email = "vimal.saini25@gmail.com"}
11
+ ]
12
+ readme = "README.md"
13
+ license = { text = "MIT" }
14
+ requires-python = ">=3.12"
15
+ dependencies = [
16
+ "httpx (>=0.28.1,<0.29.0)",
17
+ "pydantic (>=2.12.5,<3.0.0)",
18
+ "click (>=8.3.1,<9.0.0)",
19
+ "opentelemetry-sdk (>=1.40.0,<2.0.0)"
20
+ ]
21
+
22
+ [project.scripts]
23
+ acs = "acs_sdk.cli:console"
24
+
25
+ [dependency-groups]
26
+ dev = [
27
+ "pytest (>=9.0.2,<10.0.0)",
28
+ "pytest-cov (>=7.0.0,<8.0.0)",
29
+ "python-dotenv (>=1.2.2,<2.0.0)",
30
+ "ruff (>=0.15.7,<0.16.0)",
31
+ "mypy (>=1.19.1,<2.0.0)"
32
+ ]
33
+
34
+ [tool.poetry]
35
+ packages = [
36
+ { include = "acs_sdk", from = "src" }
37
+ ]
38
+
39
+ [tool.setuptools.packages.find]
40
+ where = ["src"]
41
+
42
+ [tool.pytest.ini_options]
43
+ pythonpath = ["src"]
44
+ addopts = "-ra -q --cov=acs_sdk --cov-report=term-missing"
45
+
46
+
47
+ [tool.ruff]
48
+ line-length = 100
49
+ target-version = "py312"
50
+
51
+ [tool.mypy]
52
+ strict = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,18 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="acs_sdk",
5
+ version="0.1.0",
6
+ packages=find_packages(),
7
+ install_requires=[
8
+ "httpx (>=0.28.1,<0.29.0)",
9
+ "pydantic (>=2.12.5,<3.0.0)",
10
+ "click (>=8.3.1,<9.0.0)",
11
+ "opentelemetry-sdk (>=1.40.0,<2.0.0)",
12
+ ],
13
+ author="Vimal Kumar Saini",
14
+ description="Python SDK for Apache CloudStack API",
15
+ long_description=open("README.md").read(),
16
+ long_description_content_type="text/markdown",
17
+ url="https://github.com",
18
+ )
@@ -0,0 +1,26 @@
1
+ """Apache CloudStack Python SDK.
2
+
3
+ This package provides a type-safe, modern Python interface for interacting
4
+ with Apache CloudStack environments. It handles request signing, retries,
5
+ and response parsing automatically.
6
+
7
+ Main Components:
8
+ - ApacheCloudStack: High-level entry point for SDK usage
9
+ - ApacheCloudStackConfig: Configuration management
10
+ - ApacheCloudStackClient: Low-level HTTP client
11
+
12
+ Example:
13
+ >>> from acs_sdk import ApacheCloudStack, ApacheCloudStackConfig
14
+ >>> config = ApacheCloudStackConfig(
15
+ ... api_endpoint='https://api.cloudstack.com/client/api',
16
+ ... api_key='your-key',
17
+ ... api_secret='your-secret'
18
+ ... )
19
+ >>> acs = ApacheCloudStack(config)
20
+ >>> response = acs.client.call('listUsers')
21
+ """
22
+
23
+ from .acs import ApacheCloudStack
24
+ from .schemas.config import ApacheCloudStackConfig
25
+
26
+ __all__ = ["ApacheCloudStack", "ApacheCloudStackConfig"]
@@ -0,0 +1,136 @@
1
+ """Main module for Apache CloudStack SDK.
2
+
3
+ This module provides the top-level ApacheCloudStack class that serves as
4
+ the primary interface for interacting with Apache CloudStack environments.
5
+ """
6
+
7
+ import logging
8
+ from typing import Dict, Type
9
+ from opentelemetry import trace
10
+
11
+ from acs_sdk.schemas.config import ApacheCloudStackConfig
12
+ from acs_sdk.client.client import ApacheCloudStackClient
13
+ from acs_sdk.services.account import Account
14
+ from acs_sdk.services.address import Address
15
+ from acs_sdk.services.base import BaseService
16
+ from acs_sdk.services.backup_and_recovery import BackupAndRecovery
17
+ from acs_sdk.services.disk_offering import DiskOffering
18
+ from acs_sdk.services.firewall import Firewall
19
+ from acs_sdk.services.job import Job
20
+ from acs_sdk.services.nat import NAT
21
+ from acs_sdk.services.network import Network
22
+ from acs_sdk.services.network_acl import NetworkACL
23
+ from acs_sdk.services.network_offering import NetworkOffering
24
+ from acs_sdk.services.region import Region
25
+ from acs_sdk.services.security_group import SecurityGroup
26
+ from acs_sdk.services.service_offering import ServiceOffering
27
+ from acs_sdk.services.snapshot import Snapshot
28
+ from acs_sdk.services.ssh import SSH
29
+ from acs_sdk.services.template import Template
30
+ from acs_sdk.services.usage import Usage
31
+ from acs_sdk.services.virtual_machine import VirtualMachine
32
+ from acs_sdk.services.volume import Volume
33
+ from acs_sdk.services.vpc import VPC
34
+ from acs_sdk.services.vpc_offering import VPCOffering
35
+ from acs_sdk.services.zone import Zone
36
+
37
+
38
+ class ApacheCloudStack:
39
+ """High-level interface for Apache CloudStack API interactions.
40
+
41
+ This class wraps the CloudStack client and provides a convenient entry point
42
+ for working with CloudStack resources. It handles initialization of the
43
+ client with provided configuration.
44
+
45
+ Attributes:
46
+ config (ApacheCloudStackConfig): CloudStack configuration with endpoint
47
+ and API credentials.
48
+ client (ApacheCloudStackClient): The underlying HTTP client for API
49
+ communication.
50
+
51
+ Example:
52
+ >>> config = ApacheCloudStackConfig(
53
+ ... api_key='your-key',
54
+ ... api_secret='your-secret',
55
+ ... endpoint='https://cloudstack.example.com'
56
+ ... )
57
+ >>> acs = ApacheCloudStack(config)
58
+ >>> response = acs.client.call('listUsers')
59
+ """
60
+
61
+ account: "Account"
62
+ address: "Address"
63
+ backupandrecovery: "BackupAndRecovery"
64
+ diskoffering: "DiskOffering"
65
+ firewall: "Firewall"
66
+ job: "Job"
67
+ template: "Template"
68
+ nat: "NAT"
69
+ network: "Network"
70
+ networkacl: "NetworkACL"
71
+ networkoffering: "NetworkOffering"
72
+ region: "Region"
73
+ securitygroup: "SecurityGroup"
74
+ serviceoffering: "ServiceOffering"
75
+ snapshot: "Snapshot"
76
+ ssh: "SSH"
77
+ usage: "Usage"
78
+ vm: "VirtualMachine"
79
+ volume: "Volume"
80
+ vpc: "VPC"
81
+ vpcoffering: "VPCOffering"
82
+ zone: "Zone"
83
+
84
+ _service_map: Dict[str, Type["BaseService"]] = {
85
+ "account": Account,
86
+ "address": Address,
87
+ "backupandrecovery": BackupAndRecovery,
88
+ "diskoffering": DiskOffering,
89
+ "firewall": Firewall,
90
+ "job": Job,
91
+ "nat": NAT,
92
+ "network": Network,
93
+ "networkacl": NetworkACL,
94
+ "networkoffering": NetworkOffering,
95
+ "region": Region,
96
+ "securitygroup": SecurityGroup,
97
+ "serviceoffering": ServiceOffering,
98
+ "snapshot": Snapshot,
99
+ "ssh": SSH,
100
+ "template": Template,
101
+ "vm": VirtualMachine,
102
+ "volume": Volume,
103
+ "vpc": VPC,
104
+ "vpcoffering": VPCOffering,
105
+ "usage": Usage,
106
+ "zone": Zone,
107
+ }
108
+
109
+ def __init__(
110
+ self,
111
+ config: ApacheCloudStackConfig,
112
+ tracer: trace.Tracer = None,
113
+ logger: logging.Logger = None,
114
+ ):
115
+ """Initialize the ApacheCloudStack SDK.
116
+
117
+ Args:
118
+ config (ApacheCloudStackConfig): Configuration object containing
119
+ CloudStack endpoint URL and API credentials.
120
+ tracer (trace.Tracer, optional): Tracer for API call tracing.
121
+ logger (logging.Logger, optional): Logger for API call logging.
122
+
123
+ """
124
+ self.tracer = tracer or trace.get_tracer(__name__)
125
+ self.logger = logger or logging.getLogger("cloudstack")
126
+ self.client = ApacheCloudStackClient(config, tracer=self.tracer, logger=self.logger)
127
+ self._cache = {}
128
+
129
+ def __getattr__(self, name):
130
+ """Dynamically load service classes on demand."""
131
+ if name in self._service_map:
132
+ if name not in self._cache:
133
+ self._cache[name] = self._service_map[name](self.client)
134
+ return self._cache[name]
135
+
136
+ raise AttributeError(f"{name} not found")
@@ -0,0 +1,51 @@
1
+ """Command-line interface module for Apache CloudStack SDK.
2
+
3
+ This module provides CLI functionality for interacting with Apache CloudStack
4
+ from the command line, offering a convenient alternative to programmatic usage.
5
+ """
6
+
7
+ import click
8
+
9
+ from acs_sdk.commands.service_offering import list_service_offerings
10
+ from acs_sdk.commands.vm import list_vms
11
+ from acs_sdk.commands.volume import list_volumes
12
+ from acs_sdk.commands.zone import list_zones
13
+ from acs_sdk.schemas.config import ApacheCloudStackConfig
14
+ from acs_sdk.commands.region import list_regions
15
+
16
+
17
+ @click.group()
18
+ @click.version_option(version="0.1.0")
19
+ @click.option(
20
+ "--endpoint", envvar="CLOUDSTACK_ENDPOINT", required=True, help="CloudStack API endpoint"
21
+ )
22
+ @click.option("--api-key", envvar="CLOUDSTACK_API_KEY", required=True, help="API key")
23
+ @click.option("--api-secret", envvar="CLOUDSTACK_API_SECRET", required=True, help="API secret")
24
+ @click.pass_context
25
+ def console(ctx, endpoint, api_key, api_secret):
26
+ """Main entry point for the CloudStack CLI.
27
+
28
+ This function serves as the command-line interface entry point for the
29
+ Apache CloudStack SDK. It's typically invoked when the acs command
30
+ is run from the terminal.
31
+
32
+ Example:
33
+ $ acs list-users
34
+ $ acs create-vm --template ubuntu --zone us-west-1
35
+ """
36
+ # Store config in context for child commands
37
+ ctx.ensure_object(dict)
38
+ ctx.obj["config"] = ApacheCloudStackConfig(
39
+ api_endpoint=endpoint, api_key=api_key, api_secret=api_secret, timeout=10
40
+ )
41
+
42
+
43
+ console.add_command(list_service_offerings)
44
+ console.add_command(list_regions)
45
+ console.add_command(list_zones)
46
+ console.add_command(list_vms)
47
+ console.add_command(list_volumes)
48
+
49
+
50
+ if __name__ == "__main__":
51
+ console()
File without changes