class OnenoteOperation
A class representing the status of long-running OneNote operations, extending the base Operation class with error handling capabilities.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/onenote/operations/onenote.py
5 - 11
simple
Purpose
This class provides a specialized implementation for tracking and managing long-running OneNote operations. It inherits from the Operation base class and adds specific error handling through the error property. The class is designed to monitor asynchronous OneNote API operations and provide access to error information when operations fail or encounter issues.
Source Code
class OnenoteOperation(Operation):
"""The status of certain long-running OneNote operations."""
@property
def error(self):
"""The error returned by the operation."""
return self.properties.get("error", OnenoteOperationError())
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Operation | - |
Parameter Details
__init__: The constructor parameters are inherited from the parent Operation class. No explicit __init__ method is defined in this class, so it uses the parent class constructor. Typically, Operation classes accept properties or configuration data to initialize the operation state.
Return Value
Instantiation returns an OnenoteOperation object that tracks the status of a OneNote operation. The error property returns an OnenoteOperationError object containing error details if the operation failed, or an empty OnenoteOperationError object if no error exists in the properties.
Class Interface
Methods
@property error(self) -> OnenoteOperationError
property
Purpose: Retrieves error information from the operation if an error occurred during execution
Returns: An OnenoteOperationError object containing error details if present in properties, otherwise returns an empty OnenoteOperationError object
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
properties |
dict | Inherited from parent Operation class. Stores the raw operation data including status, error information, and other operation metadata from the API response | instance |
Dependencies
office365
Required Imports
from office365.onenote.operations.onenote_operation_error import OnenoteOperationError
from office365.onenote.operations.operation import Operation
Usage Example
from office365.onenote.operations.onenote_operation import OnenoteOperation
from office365.onenote.operations.operation import Operation
# Assuming you have an operation object from a OneNote API call
# operation_data would typically come from an API response
operation_data = {'id': 'operation-123', 'status': 'running'}
# Create an OnenoteOperation instance
onenote_op = OnenoteOperation()
# Access error information if operation failed
error_info = onenote_op.error
if error_info:
print(f"Operation error: {error_info}")
# Check operation status (inherited from Operation base class)
# status = onenote_op.status
# Check if operation is complete
# is_complete = onenote_op.is_complete
Best Practices
- Always check the error property after an operation completes to handle any failures gracefully
- This class is typically instantiated by the Office 365 SDK internally when making OneNote API calls, rather than being directly instantiated by users
- The error property uses lazy evaluation and returns a default OnenoteOperationError object if no error exists, so it's safe to access without null checks
- Monitor the operation status (inherited from parent Operation class) before checking for errors
- Use this class in conjunction with OneNote API methods that return long-running operations
- The properties dictionary (inherited from parent) contains the raw operation data from the API response
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class OnenoteOperationError 72.2% similar
-
class Operation 67.7% similar
-
class Onenote 64.5% similar
-
class Notebook 57.9% similar
-
class OnenotePageCollection 57.2% similar