Official Python SDK for the SWS cloud platform
Project description
sws-sdk
Official Python SDK for the SWS cloud platform.
Install
# Once published to PyPI:
pip install sws-sdk
# Available now (installs the tagged release straight from GitHub):
pip install "git+https://github.com/savannaacloud/sws-sdk@v0.1.0"
Quickstart
from sws import Client
client = Client(api_key="ctk_...", region="ng-lagos-1")
# List virtual machines
for vm in client.compute.list_instances():
print(vm.name, vm.status)
# Launch an instance
instance = client.compute.create_instance(
name="web-01",
image="ubuntu-22.04",
plan="m1.medium",
network_id="net-uuid",
key_name="my-key",
)
# Create + attach a volume
vol = client.storage.create_volume(name="data", size=100, type="ssd")
client.storage.attach_volume(vol.id, instance_id=instance.id)
# Open SSH (port 22) from anywhere
sg = client.network.create_security_group("web", description="Allow SSH")
client.network.add_security_group_rule(
sg.id, protocol="tcp", port_range_min=22, port_range_max=22,
remote_ip_prefix="0.0.0.0/0",
)
Configure via constructor or environment variables:
| Argument | Env var | Default |
|---|---|---|
api_key |
SWS_API_KEY |
(required) |
region |
SWS_REGION |
ng-lagos-1 |
base_url |
SWS_BASE_URL |
https://savannaa.com |
Resources
| Namespace | Operations |
|---|---|
client.compute |
instances (CRUD + start/stop/reboot/resize), plans, images, keypairs |
client.network |
networks, subnets, security groups + rules, public IPs (allocate/assign/release) |
client.storage |
volumes (create, delete, attach, detach) |
client.database |
managed database instances (mysql, postgresql, …) |
Error handling
from sws import Client, QuotaExceededError, NotFoundError
try:
client.compute.create_instance(...)
except QuotaExceededError:
print("Out of instance quota — request a bump in the console.")
except NotFoundError:
print("Image or plan does not exist in this region.")
All exceptions inherit from sws.SWSError. Subclasses: AuthenticationError,
ValidationError, NotFoundError, QuotaExceededError, APIError.
Development
pip install -e ".[dev]"
pytest # unit tests use respx, no live API required
ruff check sws tests
mypy sws
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sws_sdk-0.1.1.tar.gz.
File metadata
- Download URL: sws_sdk-0.1.1.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce8b7cf69f4a6d91db450a9d9a0b30816199e8c281221cbfdfbfbdaed5c5fa35
|
|
| MD5 |
86967aa88293c3738ea08a82d2459794
|
|
| BLAKE2b-256 |
bfe6308220756af01faffea79e48e89674d8621cc39f7b70973515ae9f9a68c0
|
Provenance
The following attestation bundles were made for sws_sdk-0.1.1.tar.gz:
Publisher:
publish.yml on savannaacloud/sws-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sws_sdk-0.1.1.tar.gz -
Subject digest:
ce8b7cf69f4a6d91db450a9d9a0b30816199e8c281221cbfdfbfbdaed5c5fa35 - Sigstore transparency entry: 1943143704
- Sigstore integration time:
-
Permalink:
savannaacloud/sws-sdk@ae0d7215c3b4031890159173ce15e6e9361d3632 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/savannaacloud
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ae0d7215c3b4031890159173ce15e6e9361d3632 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sws_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sws_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
955bab3e13e2124542f58a73b32e0432b7ca25f8a839c10eea0692c7f38bd2e0
|
|
| MD5 |
cb35e8086318b7508f9249360d2f6eee
|
|
| BLAKE2b-256 |
bc104a43b84590bfbaea10d46aad632c19d54cd6599676e4e9a66944ea5a9ff0
|
Provenance
The following attestation bundles were made for sws_sdk-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on savannaacloud/sws-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sws_sdk-0.1.1-py3-none-any.whl -
Subject digest:
955bab3e13e2124542f58a73b32e0432b7ca25f8a839c10eea0692c7f38bd2e0 - Sigstore transparency entry: 1943143818
- Sigstore integration time:
-
Permalink:
savannaacloud/sws-sdk@ae0d7215c3b4031890159173ce15e6e9361d3632 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/savannaacloud
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ae0d7215c3b4031890159173ce15e6e9361d3632 -
Trigger Event:
push
-
Statement type: