Sharepoint

class O365.sharepoint.Sharepoint(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent

A Sharepoint parent class to group functionality

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

A Sharepoint site List

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_root_site()[source]

Returns the root site

Return type:

Site

get_site(*args)[source]

Returns a sharepoint site

Parameters:

args

It accepts multiple ways of retrieving a site:

get_site(host_name): the host_name: host_name ej. ‘contoso.sharepoint.com’ or ‘root’

get_site(site_id): the site_id: a comma separated string of (host_name, site_collection_id, site_id)

get_site(host_name, path_to_site): host_name ej. ‘contoso. sharepoint.com’, path_to_site: a url path (with a leading slash)

get_site(host_name, site_collection_id, site_id): host_name ej. ‘contoso.sharepoint.com’

Return type:

Site

search_site(keyword)[source]

Search a sharepoint host for sites with the provided keyword

Parameters:

keyword – a keyword to search sites

Return type:

list[Site]

class O365.sharepoint.SharepointList(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent

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

A Sharepoint site List

Parameters:
  • parent (Site) – 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)

build_field_filter(expand_fields)[source]
create_list_item(new_data)[source]

Create new list item

Parameters:

new_data – dictionary of {‘col_name’: col_value}

Return type:

SharepointListItem

delete_list_item(item_id)[source]

Delete an existing list item

Parameters:

item_id – Id of the item to be delted

get_item_by_id(item_id, expand_fields=None)[source]

Returns a sharepoint list item based on id

Parameters:
  • item_id (int) – item id to search for

  • expand_fields (list or bool) – specify user-defined fields to return, True will return all fields

Returns:

Sharepoint Item

Return type:

SharepointListItem

get_items(limit=None, *, query=None, order_by=None, batch=None, expand_fields=None)[source]

Returns a collection of Sharepoint Items

Parameters:
  • limit (int) – max no. of items to get. Over 999 uses batch.

  • query (Query or str) – applies a filter to the request.

  • order_by (Query or str) – orders the result set based on this condition

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

  • expand_fields (list or bool) – specify user-defined fields to return, True will return all fields

Returns:

list of Sharepoint Items

Return type:

list[SharepointListItem] or Pagination

get_list_columns()[source]

Returns the sharepoint list columns

column_name_cw

Column names

   Type: dict

content_types_enabled

If true, indicates that content types are enabled for this list.

   Type: bool

created

The date and time when the item was created.

   Type: datetime

created_by

Identity of the creator of this item.

   Type: Contact

description

The descriptive text for the item.

   Type: str

display_name

The displayable title of the list.

   Type: str

hidden

If true, indicates that the list isn’t normally visible in the SharePoint user experience.

   Type: bool

modified

The date and time when the item was last modified.

   Type: datetime

modified_by

Identity of the last modifier of this item.

   Type: Contact

name

The name of the item.

   Type: str

object_id

The ID of the content type.

   Type: str

template

An enumerated value that represents the base list template used in creating the list. Possible values include documentLibrary, genericList, task, survey, announcements, contacts, and more.

   Type: str

web_url

URL that displays the item in the browser.

   Type: str

class O365.sharepoint.SharepointListColumn(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent

A Sharepoint List column within a SharepointList

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

Object initialization

Parameters:
  • protocol (Protocol) – A protocol class or instance to be used with this connection

  • main_resource (str) – main_resource to be used in these API communications

column_group

For site columns, the name of the group this column belongs to.

   Type: str

description

The user-facing description of the column.

   Type: str

display_name

he user-facing name of the column.

   Type: str

enforce_unique_values

If true, no two list items may have the same value for this column.

   Type: bool

field_type

Field type of the column.

   Type: str

hidden

Specifies whether the column is displayed in the user interface.

   Type: bool

indexed

Specifies whether the column values can be used for sorting and searching.

   Type: bool

internal_name

The API-facing name of the column as it appears in the fields on a listItem.

   Type: str

object_id

The unique identifier for the column.

   Type: str

read_only

Specifies whether the column values can be modified.

   Type: bool

required

Specifies whether the column value isn’t optional.

   Type: bool

class O365.sharepoint.SharepointListItem(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent

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

A Sharepoint ListItem within a SharepointList

Parameters:
  • parent (SharepointList) – 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]
save_updates()[source]

Save the updated fields to the cloud

update_fields(updates)[source]

Update the value for a field(s) in the listitem

Parameters:

update – A dict of {‘field name’: newvalue}

content_type_id

The ID of the content type.

   Type: str

created

The date and time the item was created.

   Type: datetime

created_by

Identity of the creator of this item.

   Type: contact

fields

The fields of the item.

   Type: any

modified

The date and time the item was last modified.

   Type: datetime

modified_by

Identity of the last modifier of this item.

   Type: Contact

object_id

The unique identifier of the item.

   Type: str

web_url

URL that displays the item in the browser.

   Type: str

class O365.sharepoint.Site(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent

A Sharepoint Site

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

A Sharepoint site List

Parameters:
  • parent (Sharepoint) – 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)

create_list(list_data)[source]

Creates a SharePoint list. :param list_data: Dict representation of list. :type list_data: Dict :rtype: list[SharepointList]

get_default_document_library(request_drive=False)[source]

Returns the default document library of this site (Drive instance)

Parameters:

request_drive – True will make an api call to retrieve the drive data

Return type:

Drive

get_document_library(drive_id)[source]

Returns a Document Library (a Drive instance)

Parameters:

drive_id – the drive_id to be retrieved.

Return type:

Drive

get_list_by_name(display_name)[source]

Returns a sharepoint list based on the display name of the list

get_lists()[source]

Returns a collection of lists within this site

Return type:

list[SharepointList]

get_subsites()[source]

Returns a list of subsites defined for this site

Return type:

list[Site]

list_document_libraries()[source]

Returns a collection of document libraries for this site (a collection of Drive instances) :return: list of items in this folder :rtype: list[Drive] or Pagination

created

The date and time the item was created.

   Type: datetime

description

The descriptive text for the site.

   Type: str

display_name

The full title for the site.

   Type: str

modified

The date and time the item was last modified.

   Type: datttime

name

The name/title of the item.

   Type: str

object_id

The unique identifier of the item.

   Type: str

root

Indicates if this is the root site.

   Type: bool

site_storage

The storage for the site.

   Type: Storage

web_url

URL that displays the item in the browser.

   Type: str