Skip to content

API Reference parrot.interfaces.file.graph

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.interfaces.file.graph

View source

FileManagerInterface over Microsoft Graph drives (SharePoint and OneDrive).

Alias BatchErrorCode

Re-exported from parrot.interfaces.file.batch.BatchErrorCode.

Alias BatchItemResult

Re-exported from parrot.interfaces.file.batch.BatchItemResult.

Alias BatchState

Re-exported from parrot.interfaces.file.batch.BatchState.

Alias BatchSummary

Re-exported from parrot.interfaces.file.batch.BatchSummary.

Alias DriveEntry

Re-exported from parrot.interfaces.file.entries.DriveEntry.

Class GraphDriveFileManager

FileManagerInterface over one Microsoft Graph drive.

Paths are drive-relative and use prefix with S3-compatible semantics.

Parameter Type Default Description
prefix str '' Drive-relative folder used to scope all paths.
credentials Optional[Dict[str, Any]] None O365 credential configuration.
auth_mode AuthMode 'direct' O365 authentication mode.
user_assertion Optional[str] None Incoming user token for on-behalf-of authentication.
scopes Optional[List[str]] None Optional Graph scopes.
conflict_behavior ConflictBehavior 'replace' Upload conflict behaviour.
link_type LinkType 'view' Default sharing-link type.
link_scope LinkScope 'organization' Default sharing-link scope.
max_concurrency Optional[int] None Batch concurrency limit.
max_retries Optional[int] None Retry budget for retryable Graph responses.
chunk_size Optional[int] None Upload-session chunk size.
small_file_threshold Optional[int] None Single-request upload size threshold.
**kwargs Any {} Ignored factory or toolkit pass-through options.

Attributes:

Attribute Type Description
manager_name str
client_class type
SMALL_FILE_THRESHOLD int
CHUNK_SIZE int
MAX_CONCURRENCY int
MAX_RETRIES int
COPY_TIMEOUT_S float
RETRYABLE_STATUS frozenset
SERVING_MAX_BYTES int
ALLOWED_ORIGINS tuple
ALLOWED_HOST_SUFFIXES tuple
client O365Client Return the authenticated client after it has been connected or adopted.
drive_id str Return the resolved drive id after connection.

Method GraphDriveFileManager.connect

Build, authenticate, and resolve the drive id once.

connect() -> 'GraphDriveFileManager'

Returns: 'GraphDriveFileManager'

Method GraphDriveFileManager.adopt_client

Reuse an authenticated client without acquiring another token.

adopt_client(client: O365Client) -> None

Parameter Type Default Description
client O365Client

Method GraphDriveFileManager.close

Close only a client owned by this manager and clear cached state.

close() -> None

Method GraphDriveFileManager.list_files

Non-recursive listing of path: files only, fnmatch pattern, all pages (S4/S8).

list_files(path: str = '', pattern: str = '*') -> List[FileMetadata]

Parameter Type Default Description
path str ''
pattern str '*'

Returns: List[FileMetadata]

Method GraphDriveFileManager.list_entries

Non-recursive listing INCLUDING folders, all pages; used by the O365 List tools (S8).

list_entries(path: str = '') -> List[DriveEntry]

Parameter Type Default Description
path str ''

Returns: List[DriveEntry]

Method GraphDriveFileManager.exists

True for files AND folders that resolve; False on 404.

exists(path: str) -> bool

Parameter Type Default Description
path str

Returns: bool

Method GraphDriveFileManager.get_file_metadata

Metadata of one item; FileNotFoundError on 404.

get_file_metadata(path: str) -> FileMetadata

Parameter Type Default Description
path str

Returns: FileMetadata

Method GraphDriveFileManager.find_entries

Graph search when the keyword is API-safe, else a recursive walk under prefix; files only, all pages (AC20).

find_entries(keywords: Optional[Union[str, List[str]]] = None, extension: Optional[str] = None, prefix: Optional[str] = None) -> List[DriveEntry]

Parameter Type Default Description
keywords Optional[Union[str, List[str]]] None
extension Optional[str] None
prefix Optional[str] None

Returns: List[DriveEntry]

Method GraphDriveFileManager.find_files

FileManagerInterface override (abstract.py:265): find_entries mapped to FileMetadata.

find_files(keywords: Optional[Union[str, List[str]]] = None, extension: Optional[str] = None, prefix: Optional[str] = None) -> List[FileMetadata]

Parameter Type Default Description
keywords Optional[Union[str, List[str]]] None
extension Optional[str] None
prefix Optional[str] None

Returns: List[FileMetadata]

Method GraphDriveFileManager.delete_file

DELETE the item (goes to the recycle bin). False when it does not exist.

delete_file(path: str) -> bool

Parameter Type Default Description
path str

Returns: bool

Method GraphDriveFileManager.upload_file

Upload a local file or binary stream and return Graph metadata.

upload_file(source: Union[BinaryIO, Path], destination: str) -> FileMetadata

Parameter Type Default Description
source Union[BinaryIO, Path]
destination str

Returns: FileMetadata

Method GraphDriveFileManager.create_file

Upload raw bytes to path and report completion.

create_file(path: str, content: bytes) -> bool

Parameter Type Default Description
path str
content bytes

Returns: bool

Method GraphDriveFileManager.upload_file_from_bytes

Upload bytes with S3-compatible arguments and return the Graph web URL.

upload_file_from_bytes(file_obj: bytes, destination_key: str, content_type: str = 'application/octet-stream') -> str

Parameter Type Default Description
file_obj bytes
destination_key str
content_type str 'application/octet-stream'

Returns: str

Method GraphDriveFileManager.download_file

Stream a Graph download URL into a local path or writable binary stream.

download_file(source: str, destination: Union[Path, BinaryIO]) -> Path

Parameter Type Default Description
source str
destination Union[Path, BinaryIO]

Returns: Path

Method GraphDriveFileManager.copy_file

POST copy (202 + Location; never retried), then poll the validated monitor (AC6, AC21).

copy_file(source: str, destination: str) -> FileMetadata

Parameter Type Default Description
source str
destination str

Returns: FileMetadata

Method GraphDriveFileManager.create_sharing_link

POST createLink; creates a sharing permission (S3).

create_sharing_link(path: str, *, link_type: LinkType = 'view', scope: LinkScope = 'organization', expiry: int = 3600) -> str

Parameter Type Default Description
path str
link_type LinkType 'view'
scope LinkScope 'organization'
expiry int 3600

Returns: str

Method GraphDriveFileManager.get_file_url

Exact FileManagerInterface signature (abstract.py:67); wraps create_sharing_link with the defaults.

get_file_url(path: str, expiry: int = 3600) -> str

Parameter Type Default Description
path str
expiry int 3600

Returns: str

Method GraphDriveFileManager.create_folder

Create folder_name (and missing parents); an existing folder is not an error.

create_folder(folder_name: str) -> None

Parameter Type Default Description
folder_name str

Method GraphDriveFileManager.remove_folder

Delete a folder and its contents (recycle bin); FileNotFoundError when missing.

remove_folder(folder_name: str) -> None

Parameter Type Default Description
folder_name str

Method GraphDriveFileManager.rename_file

Rename and/or move a file within the drive (single PATCH).

rename_file(old_file_name: str, new_file_name: str) -> None

Parameter Type Default Description
old_file_name str
new_file_name str

Method GraphDriveFileManager.rename_folder

Rename and/or move a folder within the drive (single PATCH; task-time deviation, see Context).

rename_folder(old_folder_name: str, new_folder_name: str) -> None

Parameter Type Default Description
old_folder_name str
new_folder_name str

Method GraphDriveFileManager.upload_files

Batch upload (AC8): bounded concurrency, per-item results in input order, never raises for an item.

upload_files(items: Sequence[Tuple[Union[Path, BinaryIO, bytes], str]]) -> List[BatchItemResult]

Parameter Type Default Description
items Sequence[Tuple[Union[Path, BinaryIO, bytes], str]]

Returns: List[BatchItemResult]

Method GraphDriveFileManager.download_files

Batch download with the same semantics as upload_files.

download_files(items: Sequence[Tuple[str, Union[Path, BinaryIO]]]) -> List[BatchItemResult]

Parameter Type Default Description
items Sequence[Tuple[str, Union[Path, BinaryIO]]]

Returns: List[BatchItemResult]

Method GraphDriveFileManager.setup

Mount a size-guarded FileServingExtension (buffers whole objects — S7; guard AC22). Returns the extension.

setup(app: Any, route: str = '/data', base_url: Optional[str] = None, *, serving_max_bytes: Optional[int] = None) -> FileServingExtension

Parameter Type Default Description
app Any
route str '/data'
base_url Optional[str] None
serving_max_bytes Optional[int] None

Returns: FileServingExtension

Method GraphDriveFileManager.handle_file

Size guard then the extension's buffered handler (S3 parity with s3.py:635).

handle_file(request: Any) -> Any

Parameter Type Default Description
request Any

Returns: Any

Class GraphFileManagerError

Base error for Graph file-manager failures, with an optional status code.

Parameter Type Default Description
message str Human-readable failure description.
status_code Optional[int] None Graph HTTP response status when known.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally