Utilities API Reference
Reference for utility classes and helper functions in Gspace.
GoogleScopes
Utility class for managing Google API scopes.
pythonfrom gspace.utils.scopes import GoogleScopes
Class Methods
get_service_scopes
Get scopes for a specific service.
python@classmethod def get_service_scopes( service: str, access_level: str = "full" ) -> list[str]
Parameters:
service(str): Service name ("calendar", "gmail", "drive", etc.)access_level(str): Access level ("full", "readonly", "send", etc.)
Returns: List of scope strings
get_all_scopes
Get all available scopes.
python@classmethod def get_all_scopes() -> dict[str, list[str]]
Returns: Dictionary mapping service names to their available scopes
BatchRequestManager
Manage batch API requests for efficient API usage.
pythonfrom gspace.utils.batch_requests import BatchRequestManager
Methods
add_request
Add a request to the batch.
pythondef add_request( request: BatchRequest ) -> None
execute
Execute all batched requests.
pythondef execute() -> list[BatchResponse]
RateLimiter
Handle API rate limiting and retries.
pythonfrom gspace.utils.rate_limiter import APIRateLimiter
Methods
should_retry
Check if a request should be retried.
pythondef should_retry( error: Exception, attempt: int ) -> bool
get_retry_delay
Calculate delay before retry.
pythondef get_retry_delay(attempt: int) -> float
TokenManager
Manage authentication tokens.
pythonfrom gspace.auth.token_manager import TokenManager
Methods
get_token
Get a valid access token.
pythondef get_token() -> str
refresh_token
Refresh the access token.
pythondef refresh_token() -> None
save_token
Save token to storage.
pythondef save_token(token: dict) -> None
Logger
Logging utilities for debugging and monitoring.
pythonfrom gspace.utils.logger import get_logger
Usage
pythonlogger = get_logger("gspace.client") logger.info("Client initialized") logger.error("An error occurred") logger.debug("Debug information")