Пример #1
0
def get_all_events():
    try:
        events_result = service.events().list(calendarId='primary', ).execute()
        events = events_result.get('items', [])
        return jsonify(events)
    except Exception:
        return {"status": "unable to retrieve"}
Пример #2
0
def get_event_by_id(event_id):
    try:
        event = service.events().get(calendarId='primary',
                                     eventId=event_id).execute()
        return jsonify(event)
    except Exception:
        return {"status": "unable to retrieve"}
Пример #3
0
def delete_event_by_id(event_id):
    try:
        event = service.events().delete(calendarId='primary',
                                        eventId=event_id,
                                        sendUpdates="all").execute()
        return {"status": "deleted"}
    except Exception:
        return {"status": "resource not found or unable to delete"}
Пример #4
0
def update_event(event_id):
    try:
        event = request.data.decode()
        event = json.loads(event)
        updated_event = service.events().update(calendarId='primary',
                                                eventId=event_id,
                                                body=event).execute()
        return jsonify(updated_event)
    except Exception:
        return {"status": "unable to update"}