Initial commit: Vultr API v2 Python wrapper with FastAPI server

- vultr_api/: Python library wrapping Vultr API v2
  - 17 resource modules (instances, dns, firewall, vpc, etc.)
  - Pagination support, error handling

- server/: FastAPI REST server
  - All API endpoints exposed via HTTP
  - X-API-Key header authentication
  - Swagger docs at /docs

- Podman quadlet config for systemd deployment

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
HWANG BYUNGHA
2026-01-22 01:08:17 +09:00
commit 184054c6c1
48 changed files with 6058 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
"""
SSH Keys Resource
SSH key management
"""
from typing import Dict, List
from .base import BaseResource
class SSHKeysResource(BaseResource):
"""
SSH key management
Usage:
# List keys
keys = client.ssh_keys.list()
# Create key
key = client.ssh_keys.create(
name="my-key",
ssh_key="ssh-rsa AAAAB3..."
)
# Delete key
client.ssh_keys.delete("key-id")
"""
def list(self, per_page: int = 100, cursor: str = None) -> Dict:
"""
List SSH keys
Returns:
Dict with 'ssh_keys' list and 'meta' pagination
"""
params = {"per_page": per_page}
if cursor:
params["cursor"] = cursor
return self.client.get("ssh-keys", params=params)
def list_all(self) -> List[Dict]:
"""List all SSH keys (auto-paginate)"""
return self.client.paginate("ssh-keys", "ssh_keys")
def get(self, ssh_key_id: str) -> Dict:
"""
Get SSH key details
Args:
ssh_key_id: SSH key ID
Returns:
SSH key details
"""
response = self.client.get(f"ssh-keys/{ssh_key_id}")
return response.get("ssh_key", {})
def create(self, name: str, ssh_key: str) -> Dict:
"""
Create an SSH key
Args:
name: Key name
ssh_key: Public key content
Returns:
Created SSH key details
"""
response = self.client.post("ssh-keys", {
"name": name,
"ssh_key": ssh_key
})
return response.get("ssh_key", {})
def update(self, ssh_key_id: str, name: str = None, ssh_key: str = None) -> None:
"""
Update an SSH key
Args:
ssh_key_id: Key ID
name: New name
ssh_key: New public key content
"""
data = {}
if name:
data["name"] = name
if ssh_key:
data["ssh_key"] = ssh_key
self.client.patch(f"ssh-keys/{ssh_key_id}", data)
def delete(self, ssh_key_id: str) -> None:
"""
Delete an SSH key
Args:
ssh_key_id: Key ID to delete
"""
self.client.delete(f"ssh-keys/{ssh_key_id}")