Skip to content

botcity.plugins.ms365.onedrive.plugin.MS365OneDrivePlugin

default_drive: Drive property writable

The default drive reference.

You can use this property to manage drive items.

default_site: Site property writable

The default Sharepoint site that will be used as a reference.

onedrive_service: Storage property readonly

The Office365/Microsoft365 account service.

You can use this property to access OneDrive functionality.

sharepoint_service: Sharepoint property readonly

The Office365/Microsoft365 account service.

You can use this property to access Sharepoint functionality.

__init__(self, service_account, use_sharepoint=False, host_name='', path_to_site='') special

MS365OneDrivePlugin.

Parameters:

Name Type Description Default
service_account MS365CredentialsPlugin

The authenticated Microsoft365 account. The authentication process must be done through the credentials plugin.

required
use_sharepoint bool

Whether or not to use Sharepoint service. Defaults to False.

False
host_name str

The Sharepoint hostname. Example: "yourcompany.sharepoint.com".

''
path_to_site str

The path to access the Sharepoint site. Example: "sites/Site-To-Access".

''

create_folder(self, folder_name, create_on_path='')

Create a folder on OneDrive.

Parameters:

Name Type Description Default
folder_name str

The name of the folder to be created.

required
create_on_path str

The path in OneDrive where the folder will be created. The path must be used in the pattern: /path/to/parent/folder. Defaults to root folder.

''

Returns:

Type Description
DriveItem

The reference for the created folder.

delete_file(self, file_path)

Delete a file stored on OneDrive.

Parameters:

Name Type Description Default
file_path str

The path of the file in OneDrive. The file path must be used in the pattern: /path/to/file

required

download_file(self, file_path, to_path='')

Download a file stored on OneDrive.

Parameters:

Name Type Description Default
file_path str

The file path in OneDrive. The path must be used in the pattern: /path/to/file.

required
to_path str

The path where the file will be saved. Defaults to the current working dir.

''

get_drives_from_onedrive(self)

Get a list of all drives linked to the service account.

Returns:

Type Description
List[Drive]

The list containing the found drives.

get_file_by_name(self, file_name)

Search for a OneDrive item using its name.

Parameters:

Name Type Description Default
file_name str

The name of the file to be fetched.

required

Returns:

Type Description
DriveItem

The found item.

get_file_by_path(self, file_path)

Search for a item using its path on OneDrive.

The file path must be used in the pattern: /path/to/file

Parameters:

Name Type Description Default
file_path str

The path of the file to be fetched.

required

Returns:

Type Description
DriveItem

The found item.

get_files(self)

Get a list of all files and folders in the OneDrive root folder.

Returns:

Type Description
List[DriveItem]

The list containing the found files.

get_files_from_parent_folder(self, folder_path)

Get a list of all files and folders from a specific parent folder.

Parameters:

Name Type Description Default
folder_path str

The parent folder path in OneDrive. The path must be used in the pattern: /path/to/parent/folder.

required

Returns:

Type Description
List[DriveItem]

The list containing the found files.

set_sharepoint_site(self, host_name, path_to_site)

Set a Sharepoint site and get its default document library as the default drive.

Parameters:

Name Type Description Default
host_name str

The Sharepoint hostname. Example: "yourcompany.sharepoint.com".

required
path_to_site str

The path to access the Sharepoint site. Example: "sites/Site-To-Access".

required

upload_file(self, local_file_path, destination_folder_path='')

Upload a file on OneDrive.

Parameters:

Name Type Description Default
local_file_path str

The path of the file to be uploaded.

required
destination_folder_path str

The destination folder path in OneDrive. The path must be used in the pattern: /path/to/parent/folder. Defaults to root folder.

''

Returns:

Type Description
DriveItem

The reference for the uploaded file.