Utilities API Reference

Reference for utility classes and helper functions in Gspace.

GoogleScopes

Utility class for managing Google API scopes.

python
from 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.

python
from gspace.utils.batch_requests import BatchRequestManager

Methods

add_request

Add a request to the batch.

python
def add_request(
    request: BatchRequest
) -> None

execute

Execute all batched requests.

python
def execute() -> list[BatchResponse]

RateLimiter

Handle API rate limiting and retries.

python
from gspace.utils.rate_limiter import APIRateLimiter

Methods

should_retry

Check if a request should be retried.

python
def should_retry(
    error: Exception,
    attempt: int
) -> bool

get_retry_delay

Calculate delay before retry.

python
def get_retry_delay(attempt: int) -> float

TokenManager

Manage authentication tokens.

python
from gspace.auth.token_manager import TokenManager

Methods

get_token

Get a valid access token.

python
def get_token() -> str

refresh_token

Refresh the access token.

python
def refresh_token() -> None

save_token

Save token to storage.

python
def save_token(token: dict) -> None

Logger

Logging utilities for debugging and monitoring.

python
from gspace.utils.logger import get_logger

Usage

python
logger = get_logger("gspace.client")
logger.info("Client initialized")
logger.error("An error occurred")
logger.debug("Debug information")