OneDrive Actions
OneDrive Actions allow interaction with OneDrive files and folders using Microsoft Graph API.
Actions
onedrive.get_client
Create a GraphServiceClient instance to interact with OneDrive.
Parameters:
- client_id – Client ID for Azure application.
- tenant_id – Tenant ID for Azure application.
- client_secret – Client secret for Azure application.
Returns:
- client – GraphServiceClient instance.
Exceptions:
- InvalidParameters – If any required parameter is missing.
- WrongVarType – If any parameter is of wrong type.
- AzureClientAuthenticationError – If authentication fails.
- ConnectionException – For unexpected connection issues.
onedrive.get_user_id
Get the OneDrive user ID for a specific email.
Parameters:
- client – GraphServiceClient instance.
- target_user_email – Email of the target user.
Returns:
- user_id – ID of the target user.
Exceptions:
- InvalidParameters – If any required parameter is missing.
- WrongVarType – If any parameter is of wrong type.
- AzureClientAuthenticationError – If authentication fails.
- MicrosoftGraphAPIError – If API returns error or access is unauthorized.
- ConnectionException – For unexpected connection issues.
onedrive.get_drive_id
Get the OneDrive drive ID for a specific user.
Parameters:
- client – GraphServiceClient instance.
- user_id – ID of the target user.
Returns:
- drive_id – Drive ID of the user’s OneDrive.
Exceptions:
- InvalidParameters, WrongVarType, AzureClientAuthenticationError, MicrosoftGraphAPIError, ConnectionException
onedrive.get_items_by_path
Get items from a OneDrive folder filtered by optional regex.
Parameters:
- client – GraphServiceClient instance.
- drive_id – Drive ID of the target user.
- path – Path to search.
- regex (optional) – Regex to filter items by name.
Returns:
- total – Number of items found.
- items – List of items with name, id, type, lastModifiedDateTime.
Exceptions:
- InvalidParameters, WrongVarType, AzureClientAuthenticationError, MicrosoftGraphAPIError, OneDriveFolderNotFound, ConnectionException
onedrive.download_file_by_id
Download a file from OneDrive by its ID.
Parameters:
- client – GraphServiceClient instance.
- drive_id – Drive ID of the target user.
- item_id – ID of the file.
- download_path – Path to save the downloaded file.
Returns:
- download_path – Path where the file was saved.
Exceptions:
- InvalidParameters, WrongVarType, AzureClientAuthenticationError, MicrosoftGraphAPIError, OneDriveFolderNotFound, ConnectionException
onedrive.move_item
Move an item in OneDrive to another folder.
Parameters:
- client – GraphServiceClient instance.
- drive_id – Drive ID of the target user.
- item_id – ID of the item to move.
- destination_id – ID of the destination folder.
- new_name (optional) – New name for the item.
Returns:
- id – ID of the moved item.
- name – Name of the moved item.
- parent_reference_id – ID of the destination folder.
Exceptions:
- InvalidParameters, WrongVarType, AzureClientAuthenticationError, MicrosoftGraphAPIError, OneDriveFolderNotFound, ConnectionException