Files
vultr-api/server/routers/account.py
HWANG BYUNGHA 184054c6c1 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>
2026-01-22 01:08:17 +09:00

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)