""" Account Resource Includes account info and ACL (Access Control List) management """ from typing import Dict, List, Optional from .base import BaseResource class AccountResource(BaseResource): """ Account and ACL management Usage: # Get account info account = client.account.get() # Get bandwidth bandwidth = client.account.get_bandwidth() # ACL (IP access control) acl = client.account.get_acl() client.account.set_acl(acls=["192.168.1.1/32", "10.0.0.0/8"]) """ def get(self) -> Dict: """ Get account information Returns: Account info including name, email, balance, etc. """ response = self.client.get("account") return response.get("account", {}) def get_bandwidth(self) -> Dict: """ Get account bandwidth usage Returns: Bandwidth usage info """ return self.client.get("account/bandwidth") # ACL (Access Control List) methods def get_acl(self) -> Dict: """ Get API access control list Returns: ACL info including enabled status and list of allowed IPs/CIDRs """ return self.client.get("account/acl") def set_acl(self, acls: List[str]) -> Dict: """ Update API access control list Args: acls: List of IP addresses or CIDR ranges to allow. Pass empty list to disable ACL. Returns: Updated ACL info Example: # Allow specific IPs client.account.set_acl(["192.168.1.100/32", "10.0.0.0/8"]) # Disable ACL (allow all) client.account.set_acl([]) """ return self.client.post("account/acl", {"acls": acls}) def add_acl(self, ip: str) -> Dict: """ Add an IP/CIDR to the ACL Args: ip: IP address or CIDR to add (e.g., "192.168.1.1/32") Returns: Updated ACL info """ current = self.get_acl() acls = current.get("acls", []) if ip not in acls: acls.append(ip) return self.set_acl(acls) def remove_acl(self, ip: str) -> Dict: """ Remove an IP/CIDR from the ACL Args: ip: IP address or CIDR to remove Returns: Updated ACL info """ current = self.get_acl() acls = current.get("acls", []) if ip in acls: acls.remove(ip) return self.set_acl(acls) def clear_acl(self) -> Dict: """ Clear all ACL entries (disable ACL) Returns: Updated ACL info """ return self.set_acl([])