Tasks

Methods for accessing MS Tasks/Todos via the MS Graph api.

class O365.tasks.ChecklistItem(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent

A Microsoft To-Do task CheckList Item.

__init__(*, parent=None, con=None, **kwargs)[source]

Representation of a Microsoft To-Do task CheckList Item.

Parameters:
  • parent (Task) – parent object

  • con (Connection) – connection to use if no parent specified

  • protocol (Protocol) – protocol to use if no parent specified (kwargs)

  • main_resource (str) – use this resource instead of parent resource (kwargs)

  • task_id (str) – id of the task to add this item in (kwargs)

  • displayName (str) – display name of the item (kwargs)

delete()[source]

Delete a stored checklist item.

Returns:

Success / Failure

Return type:

bool

mark_checked()[source]

Mark the checklist item as checked.

mark_unchecked()[source]

Mark the checklist item as unchecked.

save()[source]

Create a new checklist item or update an existing one.

Does update by checking what values have changed and update them on the server :return: Success / Failure :rtype: bool

to_api_data(restrict_keys=None)[source]

Return a dict to communicate with the server.

Parameters:

restrict_keys – a set of keys to restrict the returned data to

Return type:

dict

property checked

Return Checked time of the task.

Type:

datetime

property created

Return Created time of the task.

Type:

datetime

property displayname

Return Display Name of the task.

Type:

str

folder_id

Identifier of the folder of the containing task.

   Type: str

property is_checked

Is the item checked.

Type:

bool

item_id

Unique identifier for the item.

   Type: str

task_id

Identifier of the containing task.

   Type: str

class O365.tasks.Folder(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent

A Microsoft To-Do folder.

__init__(*, parent=None, con=None, **kwargs)[source]

Representation of a Microsoft To-Do Folder.

Parameters:
  • parent (ToDo) – parent object

  • con (Connection) – connection to use if no parent specified

  • protocol (Protocol) – protocol to use if no parent specified (kwargs)

  • main_resource (str) – use this resource instead of parent resource (kwargs)

delete()[source]

Delete this folder.

Returns:

Success / Failure

Return type:

bool

get_task(param)[source]

Return a Task instance by it’s id.

Parameters:

param – an task_id or a Query instance

Returns:

task for the specified info

Return type:

Task

get_tasks(query=None, batch=None, order_by=None)[source]

Return list of tasks of a specified folder.

Parameters:
  • query – the query string or object to query tasks

  • batch – the batch on to retrieve tasks.

  • order_by – the order clause to apply to returned tasks.

Return type:

tasks

new_task(subject=None)[source]

Create a task within a specified folder.

update()[source]

Update this folder. Only name can be changed.

Returns:

Success / Failure

Return type:

bool

folder_id

The identifier of the task list, unique in the user’s mailbox.

   Type: str

is_default

Is the defaultList.

   Type: bool

name

The name of the task list.

   Type: str

class O365.tasks.Pattern(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent

The recurrence pattern.

__init__(*, parent=None, con=None, **kwargs)[source]

Representation of recurrence pattern settings.

Parameters:
  • parent (Recurrence) – parent object

  • con (Connection) – connection to use if no parent specified

  • protocol (Protocol) – protocol to use if no parent specified (kwargs)

  • main_resource (str) – use this resource instead of parent resource (kwargs)

property day_of_month

The day of the month on which the task occurs.

Type:

int

property days_of_week

A collection of the days of the week on which the event occurs.

Type:

list(str)

property first_day_of_the_week

The first day of the week.

Type:

str

property index

Specifies on which instance of the allowed days specified in daysOfWeek the event occurs, counted from the first instance in the month.

Type:

weekindex

property interval

The number of units between occurrences, where units can be in days, weeks, months, or years, depending on the type.

Type:

int

property month

The month in which the event occurs.

Type:

int

property pattern_type

Specifies on which instance of the allowed days specified in daysOfWeek the event occurs, counted from the first instance in the month.

Type:

recurrencepatterntype

class O365.tasks.Range(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent

The recurrence range.

__init__(*, parent=None, con=None, **kwargs)[source]

Representation of recurrence range settings.

Parameters:
  • parent (Recurrence) – parent object

  • con (Connection) – connection to use if no parent specified

  • protocol (Protocol) – protocol to use if no parent specified (kwargs)

  • main_resource (str) – use this resource instead of parent resource (kwargs)

property end_date

The date to stop applying the recurrence pattern.

Type:

date

property no_of_occurrences

The number of times to repeat the event.

Type:

int

property range_type

The recurrence range.

Type:

recurrencerangetype

property recurrence_timezone

Time zone for the startDate and endDate properties.

Type:

str

property start_date

The date to start applying the recurrence pattern.

Type:

date

class O365.tasks.Recurrence(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent

The recurrence Pattern and Range.

__init__(*, parent=None, con=None, **kwargs)[source]

Representation of recurrence settings.

Parameters:
  • parent (Task) – parent object

  • con (Connection) – connection to use if no parent specified

  • protocol (Protocol) – protocol to use if no parent specified (kwargs)

  • main_resource (str) – use this resource instead of parent resource (kwargs)

pattern

The recurrence pattern for the recurrences

   Type: Pattern

range

The recurrence range for the recurrences

   Type: Range

class O365.tasks.RecurrencePatternType(*values)[source]

Bases: Enum

Valid values for recurrencePatternType.

ABSOLUTEMONTHLY = 'absoluteMonthly'
ABSOLUTEYEARLY = 'absoluteYearly'
DAILY = 'daily'
RELATIVEMONTHLY = 'relativeMonthly'
RELATIVEYEARLY = 'relativeYearly'
WEEKLY = 'weekly'
class O365.tasks.RecurrenceRangeType(*values)[source]

Bases: Enum

Valid values for recurrenceRangeType.

ENDDATE = 'endDate'
NOEND = 'noEnd'
NUMBERED = 'numbered'
class O365.tasks.Task(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent

A Microsoft To-Do task.

__init__(*, parent=None, con=None, **kwargs)[source]

Representation of a Microsoft To-Do task.

Parameters:
  • parent (Folder) – parent object

  • con (Connection) – connection to use if no parent specified

  • protocol (Protocol) – protocol to use if no parent specified (kwargs)

  • main_resource (str) – use this resource instead of parent resource (kwargs)

  • folder_id (str) – id of the calender to add this task in (kwargs)

  • subject (str) – subject of the task (kwargs)

delete()[source]

Delete a stored task.

Returns:

Success / Failure

Return type:

bool

get_body_soup()[source]

Return the beautifulsoup4 of the html body.

Returns:

Html body

Return type:

BeautifulSoup

get_body_text()[source]

Parse the body html and returns the body text using bs4.

Returns:

body text

Return type:

str

get_checklist_item(param)[source]

Return a Checklist Item instance by it’s id.

Parameters:

param – an item_id or a Query instance

Returns:

Checklist Item for the specified info

Return type:

ChecklistItem

get_checklist_items(query=None, batch=None, order_by=None)[source]

Return list of checklist items of a specified task.

Parameters:
  • query – the query string or object to query items

  • batch – the batch on to retrieve items.

  • order_by – the order clause to apply to returned items.

Return type:

checklistItems

mark_completed()[source]

Mark the task as completed.

mark_uncompleted()[source]

Mark the task as uncompleted.

new_checklist_item(displayname=None)[source]

Create a checklist item within a specified task.

save()[source]

Create a new task or update an existing one.

Does update by checking what values have changed and update them on the server :return: Success / Failure :rtype: bool

to_api_data(restrict_keys=None)[source]

Return a dict to communicate with the server.

Parameters:

restrict_keys – a set of keys to restrict the returned data to

Return type:

dict

property body

Return Body of the task.

Getter:

Get body text

Setter:

Set body of task

Type:

str

body_type

The type of the content. Possible values are text and html.

   Type: str

property checklist_items

Checklist items for the task.

Getter:

Get checklistItems

Type:

list[ChecklistItem]

property completed

Completed Time of task.

Getter:

Get the completed time

Setter:

Set the completed time

Type:

datetime

property created

Return Created time of the task.

Type:

datetime

property due

Due Time of task.

Getter:

Get the due time

Setter:

Set the due time

Type:

datetime

folder_id

Identifier of the containing folder.

   Type: str

property importance

Return Task importance.

Getter:

Get importance level (Low, Normal, High)

Type:

str

property is_completed

Is task completed or not.

Getter:

Is completed

Setter:

Set the task to completed

Type:

bool

property is_reminder_on

Return isReminderOn of the task.

Getter:

Get isReminderOn

Type:

bool

property is_starred

Is the task starred (high importance).

Getter:

Check if importance is high

Type:

bool

property modified

Return Last modified time of the task.

Type:

datetime

property reminder

Reminder Time of task.

Getter:

Get the reminder time

Setter:

Set the reminder time

Type:

datetime

property status

Status of task

Getter:

Get status

Type:

str

property subject

Subject of the task.

Getter:

Get subject

Setter:

Set subject of task

Type:

str

task_id

Unique identifier for the task.

   Type: str

class O365.tasks.ToDo(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent

A Microsoft To-Do class for MS Graph API.

In order to use the API following permissions are required. Delegated (work or school account) - Tasks.Read, Tasks.ReadWrite

__init__(*, parent=None, con=None, **kwargs)[source]

Initialise the ToDo object.

Parameters:
  • parent (Account) – parent object

  • con (Connection) – connection to use if no parent specified

  • protocol (Protocol) – protocol to use if no parent specified (kwargs)

  • main_resource (str) – use this resource instead of parent resource (kwargs)

get_default_folder()[source]

Return the default folder for the current user.

Return type:

Folder

get_folder(folder_id=None, folder_name=None)[source]

Return a folder by it’s id or name.

Parameters:
  • folder_id (str) – the folder id to be retrieved.

  • folder_name (str) – the folder name to be retrieved.

Returns:

folder for the given info

Return type:

Folder

get_tasks(batch=None, order_by=None)[source]

Get tasks from the default Folder.

Parameters:
  • order_by – orders the result set based on this condition

  • batch (int) – batch size, retrieves items in batches allowing to retrieve more items than the limit.

Returns:

list of items in this folder

Return type:

list[Task] or Pagination

list_folders(query=None, limit=None)[source]

Return a list of folders.

To use query an order_by check the OData specification here: https://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/ part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions -complete.html :param query: the query string or object to list folders :param int limit: max no. of folders to get. Over 999 uses batch. :rtype: list[Folder]

list_folders_delta(query=None, limit=None)[source]

Return a list of folders using the delta endpoint.

To use query an order_by check the OData specification here: https://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/ part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions -complete.html :param query: the query string or object to list folders :param int limit: max no. of folders to get. Over 999 uses batch. :rtype: list[Folder]

new_folder(folder_name)[source]

Create a new folder.

Parameters:

folder_name (str) – name of the new folder

Returns:

a new folder instance

Return type:

Folder

new_task(subject=None)[source]

Return a new (unsaved) Task object in the default folder.

Parameters:

subject (str) – subject text for the new task

Returns:

new task

Return type:

Task

class O365.tasks.WeekIndex(*values)[source]

Bases: Enum

Valid values for weekIndex.

FIRST = 'first'
FOURTH = 'fourth'
LAST = 'last'
SECOND = 'second'
THIRD = 'third'