<commit_before>.. _events:

Events
======

Event in `gcsa` is represented by the class :py:class:`~gcsa.event.Event`. It stores all needed information about event
including its summary, starting and ending dates/times, attachments, reminders, recurrence rules, etc.

Current version of `gcsa` allows you to create a new events, retrieve, update, move and delete existing events.

To do so, create a ``GoogleCalendar`` instance (see :ref:`getting_started` to get your credentials):

.. code-block:: python

    from gcsa.google_calendar import GoogleCalendar

    calendar = GoogleCalendar()

List events
~~~~~~~~~~~
This code will print out events for one year starting today:


.. code-block:: python

    for event in calendar:
        print(event)


Specify range of listed events in two ways:

.. code-block:: python

    calendar.get_events(start_date, end_date, order_by='updated')

or

.. code-block:: python

    calendar[start_date:end_date:'updated']

``start_date`` and ``end_date`` can be ``date`` or ``datetime`` objects. ``order_by`` can be `'startTime'` (default)
or `'updated'`.

Get event by id
~~~~~~~~~~~~~~~

.. code-block:: python

    calendar.get_event('<event_id>')



Create event
~~~~~~~~~~~~

.. code-block:: python

    from beautiful_date import Apr

    event = Event('Meeting',
                  start=(22/Apr/2019)[12:00],
                  end=(22/Apr/2019)[13:00])


For ``date``/``datetime`` objects you can use Pythons datetime_ module or as in the
example beautiful_date_ library (*because it's beautiful... just like you*).


Now **add** your event to the calendar:

.. code-block:: python<commit_msg>Add docs for query and single_events of get_events<commit_after>.. _events:

Events
======

Event in `gcsa` is represented by the class :py:class:`~gcsa.event.Event`. It stores all needed information about event
including its summary, starting and ending dates/times, attachments, reminders, recurrence rules, etc.

Current version of `gcsa` allows you to create a new events, retrieve, update, move and delete existing events.

To do so, create a ``GoogleCalendar`` instance (see :ref:`getting_started` to get your credentials):

.. code-block:: python

    from gcsa.google_calendar import GoogleCalendar

    calendar = GoogleCalendar()

List events
~~~~~~~~~~~
This code will print out events for one year starting today:


.. code-block:: python

    for event in calendar:
        print(event)


Specify range of listed events in two ways:

.. code-block:: python

    calendar.get_events(start_date, end_date, order_by='updated')

or

.. code-block:: python

    calendar[start_date:end_date:'updated']

``start_date`` and ``end_date`` can be ``date`` or ``datetime`` objects. ``order_by`` can be `'startTime'` (default)
or `'updated'`.


Use ``query`` parameter for free text search through all event fields (except for extended properties):

.. code-block:: python

    calendar.get_events(query='Meeting')
    calendar.get_events(query='John') # Name of attendee

Use ``single_events`` parameter to expand recurring events into instances and only return single one-off events and
instances of recurring events, but not the underlying recurring events themselves.

.. code-block:: python

    calendar.get_events(single_events=True)


Get event by id
~~~~~~~~~~~~~~~

.. code-block:: python

    calendar.get_event('<event_id>')



Create event
~~~~~~~~~~~~

.. code-block:: python

    from beautiful_date import Apr

    event = Event('Meeting',
                  start=(22/Apr/2019)[12:00],
                  end=(22/Apr/2019)[13:00])


For ``date``/``datetime`` objects you can use Pythons datetime_ module or as in the
example beautiful_date_ library (*because it's beautiful... just like you*).


Now **add** your event to the calendar:

.. code-block:: python
{'fraction_non_alphanumeric': 0.13083377031987414, 'fraction_numerical': 0.01048767697954903, 'mean_word_length': 3.9674479166666665, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5733075', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1059, 'n_words': 404}