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:
38
server/routers/account.py
Normal file
38
server/routers/account.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""Account router"""
|
||||
from fastapi import APIRouter, Depends
|
||||
from typing import List
|
||||
|
||||
from vultr_api import VultrClient
|
||||
from deps import get_client
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("")
|
||||
async def get_account(client: VultrClient = Depends(get_client)):
|
||||
"""Get account information"""
|
||||
return client.account.get()
|
||||
|
||||
|
||||
@router.get("/acl")
|
||||
async def get_acl(client: VultrClient = Depends(get_client)):
|
||||
"""Get account ACL (IP access control list)"""
|
||||
return client.account.get_acl()
|
||||
|
||||
|
||||
@router.put("/acl")
|
||||
async def set_acl(acls: List[str], client: VultrClient = Depends(get_client)):
|
||||
"""Set account ACL"""
|
||||
return client.account.set_acl(acls)
|
||||
|
||||
|
||||
@router.post("/acl")
|
||||
async def add_acl(ip: str, client: VultrClient = Depends(get_client)):
|
||||
"""Add IP to ACL"""
|
||||
return client.account.add_acl(ip)
|
||||
|
||||
|
||||
@router.delete("/acl/{ip}")
|
||||
async def remove_acl(ip: str, client: VultrClient = Depends(get_client)):
|
||||
"""Remove IP from ACL"""
|
||||
return client.account.remove_acl(ip)
|
||||
Reference in New Issue
Block a user