@@ -1780,8 +1780,9 @@ def delete(self):
17801780
17811781 return True
17821782
1783- def get_events (self , limit = 25 , * , query = None , order_by = None , batch = None ,
1784- download_attachments = False , include_recurring = True ):
1783+ def get_events (self , limit : int = 25 , * , query = None , order_by = None , batch = None ,
1784+ download_attachments = False , include_recurring = True ,
1785+ start_recurring = None , end_recurring = None ):
17851786 """ Get events from this Calendar
17861787
17871788 :param int limit: max no. of events to get. Over 999 uses batch.
@@ -1793,6 +1794,8 @@ def get_events(self, limit=25, *, query=None, order_by=None, batch=None,
17931794 batches allowing to retrieve more items than the limit.
17941795 :param download_attachments: downloads event attachments
17951796 :param bool include_recurring: whether to include recurring events or not
1797+ :param start_recurring: a string datetime or a Query object with just a start condition
1798+ :param end_recurring: a string datetime or a Query object with just an end condition
17961799 :return: list of events in this calendar
17971800 :rtype: list[Event] or Pagination
17981801 """
@@ -1822,22 +1825,29 @@ def get_events(self, limit=25, *, query=None, order_by=None, batch=None,
18221825 if include_recurring :
18231826 start = None
18241827 end = None
1825- if query and not isinstance (query , str ):
1826- # extract start and end from query because
1827- # those are required by a calendarView
1828- start = query .get_filter_by_attribute ('start/' )
1829- end = query .get_filter_by_attribute ('start/' )
1830-
1831- if start :
1832- start = start .replace ("'" , '' ) # remove the quotes
1833- query .remove_filter ('start' )
1834- if end :
1835- end = end .replace ("'" , '' ) # remove the quotes
1836- query .remove_filter ('end' )
1837-
1828+ if start_recurring is None :
1829+ pass
1830+ elif isinstance (start_recurring , str ):
1831+ start = start_recurring
1832+ elif isinstance (start_recurring , dt .datetime ):
1833+ start = start_recurring .isoformat ()
1834+ else :
1835+ # it's a Query Object
1836+ start = start_recurring .get_filter_by_attribute ('start/' )
1837+ if end_recurring is None :
1838+ pass
1839+ elif isinstance (end_recurring , str ):
1840+ end = end_recurring
1841+ elif isinstance (end_recurring , dt .datetime ):
1842+ end = end_recurring .isoformat ()
1843+ else :
1844+ # it's a Query Object
1845+ end = end_recurring .get_filter_by_attribute ('end/' )
18381846 if start is None or end is None :
18391847 raise ValueError ("When 'include_recurring' is True you must provide "
1840- "a 'start' and 'end' datetime inside a 'Query' instance." )
1848+ "a 'start_recurring' and 'end_recurring' with a datetime string." )
1849+ start = start .replace ("'" , '' ) # remove the quotes
1850+ end = end .replace ("'" , '' ) # remove the quotes
18411851
18421852 params [self ._cc ('startDateTime' )] = start
18431853 params [self ._cc ('endDateTime' )] = end
@@ -2088,9 +2098,19 @@ def get_default_calendar(self):
20882098 return self .calendar_constructor (parent = self ,
20892099 ** {self ._cloud_data_key : data })
20902100
2091- def get_events (self , limit = 25 , * , query = None , order_by = None , batch = None ,
2092- download_attachments = False , include_recurring = True ):
2093- """ Get events from the default Calendar
2101+ def get_events (
2102+ self ,
2103+ limit = 25 ,
2104+ * ,
2105+ query = None ,
2106+ order_by = None ,
2107+ batch = None ,
2108+ download_attachments = False ,
2109+ include_recurring = True ,
2110+ start_recurring = None ,
2111+ end_recurring = None ,
2112+ ):
2113+ """Get events from the default Calendar
20942114
20952115 :param int limit: max no. of events to get. Over 999 uses batch.
20962116 :param query: applies a OData filter to the request
@@ -2101,16 +2121,24 @@ def get_events(self, limit=25, *, query=None, order_by=None, batch=None,
21012121 batches allowing to retrieve more items than the limit.
21022122 :param bool download_attachments: downloads event attachments
21032123 :param bool include_recurring: whether to include recurring events or not
2124+ :param start_recurring: a string datetime or a Query object with just a start condition
2125+ :param end_recurring: a string datetime or a Query object with just an end condition
21042126 :return: list of items in this folder
21052127 :rtype: list[Event] or Pagination
21062128 """
21072129
21082130 default_calendar = self .calendar_constructor (parent = self )
21092131
2110- return default_calendar .get_events (limit = limit , query = query ,
2111- order_by = order_by , batch = batch ,
2112- download_attachments = download_attachments ,
2113- include_recurring = include_recurring )
2132+ return default_calendar .get_events (
2133+ limit = limit ,
2134+ query = query ,
2135+ order_by = order_by ,
2136+ batch = batch ,
2137+ download_attachments = download_attachments ,
2138+ include_recurring = include_recurring ,
2139+ start_recurring = start_recurring ,
2140+ end_recurring = end_recurring ,
2141+ )
21142142
21152143 def new_event (self , subject = None ):
21162144 """ Returns a new (unsaved) Event object in the default calendar
0 commit comments