From c282cb61e8e7176ee116bcc09b9610787598ca82 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 5 Apr 2018 20:37:09 +0300 Subject: [PATCH] create/delete calendar --- gcal_sync/gcal.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gcal_sync/gcal.py b/gcal_sync/gcal.py index fd51423..3e94f0e 100644 --- a/gcal_sync/gcal.py +++ b/gcal_sync/gcal.py @@ -214,6 +214,33 @@ class GoogleCalendar(): i += 1 batch.execute() + def create(self, summary, timeZone=None): + """create calendar + + Arguments: + summary -- new calendar summary + + Keyword Arguments: + timeZone -- new calendar timezone as string (optional) + + Returns: + calendar Resource + """ + + calendar = {'summary': summary} + if timeZone is not None: + calendar['timeZone'] = timeZone + + created_calendar = self.service.calendars().insert(body=calendar).execute() + self.calendarId = created_calendar['id'] + return created_calendar + + def delete(self): + """delete calendar + """ + + self.service.calendars().delete(calendarId=self.calendarId).execute() + def make_public(self): """make calendar puplic """