- 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>
39 lines
987 B
Python
39 lines
987 B
Python
"""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)
|