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:
65
vultr_api/resources/backups.py
Normal file
65
vultr_api/resources/backups.py
Normal file
@@ -0,0 +1,65 @@
|
||||
"""
|
||||
Backups Resource
|
||||
|
||||
Backup management
|
||||
"""
|
||||
|
||||
from typing import Dict, List
|
||||
from .base import BaseResource
|
||||
|
||||
|
||||
class BackupsResource(BaseResource):
|
||||
"""
|
||||
Backup management
|
||||
|
||||
Usage:
|
||||
# List backups
|
||||
backups = client.backups.list()
|
||||
|
||||
# Get backup details
|
||||
backup = client.backups.get("backup-id")
|
||||
"""
|
||||
|
||||
def list(
|
||||
self,
|
||||
instance_id: str = None,
|
||||
per_page: int = 100,
|
||||
cursor: str = None
|
||||
) -> Dict:
|
||||
"""
|
||||
List backups
|
||||
|
||||
Args:
|
||||
instance_id: Filter by instance ID
|
||||
per_page: Items per page
|
||||
cursor: Pagination cursor
|
||||
|
||||
Returns:
|
||||
Dict with 'backups' list and 'meta' pagination
|
||||
"""
|
||||
params = {"per_page": per_page}
|
||||
if instance_id:
|
||||
params["instance_id"] = instance_id
|
||||
if cursor:
|
||||
params["cursor"] = cursor
|
||||
return self.client.get("backups", params=params)
|
||||
|
||||
def list_all(self, instance_id: str = None) -> List[Dict]:
|
||||
"""List all backups (auto-paginate)"""
|
||||
params = {}
|
||||
if instance_id:
|
||||
params["instance_id"] = instance_id
|
||||
return self.client.paginate("backups", "backups", params=params)
|
||||
|
||||
def get(self, backup_id: str) -> Dict:
|
||||
"""
|
||||
Get backup details
|
||||
|
||||
Args:
|
||||
backup_id: Backup ID
|
||||
|
||||
Returns:
|
||||
Backup details
|
||||
"""
|
||||
response = self.client.get(f"backups/{backup_id}")
|
||||
return response.get("backup", {})
|
||||
Reference in New Issue
Block a user