Source code for langchain_google_community.calendar.get_calendars_info
"""Get information about the calendars in Google Calendar."""importjsonfromtypingimportOptionalfromlangchain_core.callbacksimportCallbackManagerForToolRunfromlangchain_google_community.calendar.baseimportCalendarBaseTool
[docs]classGetCalendarsInfo(CalendarBaseTool):# type: ignore[override, override]"""Tool that get information about the calendars in Google Calendar."""name:str="get_calendars_info"description:str=("Use this tool to get information about the calendars in Google Calendar.")def_run(self,run_manager:Optional[CallbackManagerForToolRun]=None)->str:"""Run the tool to get information about the calendars in Google Calendar."""try:calendars=self.api_resource.calendarList().list().execute()data=[]foritemincalendars.get("items",[]):data.append({"id":item["id"],"summary":item["summary"],"timeZone":item["timeZone"],})returnjson.dumps(data)exceptExceptionaserror:raiseException(f"An error occurred: {error}")fromerror