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

58
server/main.py Normal file
View File

@@ -0,0 +1,58 @@
"""
Vultr API REST Server
FastAPI wrapper for vultr-api library
"""
from fastapi import FastAPI
from contextlib import asynccontextmanager
from routers import (
account, instances, dns, firewall, ssh_keys,
startup_scripts, snapshots, block_storage, reserved_ips,
vpc, load_balancers, bare_metal, backups, plans, regions, os_api
)
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Application lifespan handler"""
print("Vultr API Server starting...")
yield
print("Vultr API Server shutting down...")
app = FastAPI(
title="Vultr API Server",
description="REST API server wrapping Vultr API v2",
version="1.0.0",
lifespan=lifespan,
)
# Include routers
app.include_router(account.router, prefix="/account", tags=["Account"])
app.include_router(instances.router, prefix="/instances", tags=["Instances"])
app.include_router(dns.router, prefix="/dns", tags=["DNS"])
app.include_router(firewall.router, prefix="/firewall", tags=["Firewall"])
app.include_router(ssh_keys.router, prefix="/ssh-keys", tags=["SSH Keys"])
app.include_router(startup_scripts.router, prefix="/startup-scripts", tags=["Startup Scripts"])
app.include_router(snapshots.router, prefix="/snapshots", tags=["Snapshots"])
app.include_router(block_storage.router, prefix="/block-storage", tags=["Block Storage"])
app.include_router(reserved_ips.router, prefix="/reserved-ips", tags=["Reserved IPs"])
app.include_router(vpc.router, prefix="/vpc", tags=["VPC"])
app.include_router(load_balancers.router, prefix="/load-balancers", tags=["Load Balancers"])
app.include_router(bare_metal.router, prefix="/bare-metal", tags=["Bare Metal"])
app.include_router(backups.router, prefix="/backups", tags=["Backups"])
app.include_router(plans.router, prefix="/plans", tags=["Plans"])
app.include_router(regions.router, prefix="/regions", tags=["Regions"])
app.include_router(os_api.router, prefix="/os", tags=["Operating Systems"])
@app.get("/", tags=["Health"])
async def root():
"""Health check endpoint"""
return {"status": "ok", "service": "vultr-api-server"}
@app.get("/health", tags=["Health"])
async def health():
"""Health check endpoint"""
return {"status": "healthy"}