Calendar Service

The Calendar service provides a simple interface for managing Google Calendar events and calendars.

Getting Started

python
from gspace import GSpace

gspace = GSpace.from_oauth(
    credentials_file="credentials.json",
    scopes=["calendar"]
)

calendar = gspace.calendar()

Creating Events

python
from datetime import datetime, timedelta

event = calendar.create_event(
    summary="Team Meeting",
    start_time=datetime.now() + timedelta(hours=1),
    end_time=datetime.now() + timedelta(hours=2),
    description="Weekly team sync",
    location="Conference Room A",
    attendees=["team@company.com"]
)

Listing Events

python
events = calendar.list_events(
    time_min=datetime.now(),
    time_max=datetime.now() + timedelta(days=7),
    max_results=20
)

for event in events:
    print(event.get('summary'))

Updating Events

python
calendar.update_event(
    event_id=event_id,
    summary="Updated Meeting Title"
)

Deleting Events

python
calendar.delete_event(event_id)

Managing Calendars

python
# List all calendars
calendars = calendar.list_calendars()

# Get calendar details
cal = calendar.get_calendar(calendar_id="primary")

# Create a new calendar
new_cal = calendar.create_calendar(
    summary="My New Calendar",
    description="Calendar for personal events"
)

Free/Busy Queries

python
free_busy = calendar.get_free_busy(
    time_min=datetime.now(),
    time_max=datetime.now() + timedelta(days=1),
    items=[{"id": "primary"}]
)