Calendar Service
The Calendar service provides a simple interface for managing Google Calendar events and calendars.
Getting Started
pythonfrom gspace import GSpace gspace = GSpace.from_oauth( credentials_file="credentials.json", scopes=["calendar"] ) calendar = gspace.calendar()
Creating Events
pythonfrom 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
pythonevents = 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
pythoncalendar.update_event( event_id=event_id, summary="Updated Meeting Title" )
Deleting Events
pythoncalendar.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
pythonfree_busy = calendar.get_free_busy( time_min=datetime.now(), time_max=datetime.now() + timedelta(days=1), items=[{"id": "primary"}] )