class PlannerTask
Represents a Microsoft 365 Planner task entity with properties for title and detailed task information.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/planner/tasks/task.py
6 - 27
simple
Purpose
The PlannerTask class provides an object-oriented interface to Microsoft 365 Planner tasks. It extends the Entity base class and encapsulates task data including the task title and detailed information. This class is part of the Office 365 SDK and is used to interact with Planner tasks within a plan, which can be assigned to buckets. It provides read-only property access to task attributes and lazy-loads related task details.
Source Code
class PlannerTask(Entity):
"""
The plannerTask resource represents a Planner task in Microsoft 365.
A Planner task is contained in a plan and can be assigned to a bucket in a plan.
Each task object has a details object which can contain more information about the task.
See overview for more information regarding relationships between group, plan and task.
"""
@property
def title(self):
"""Required. Title of the task."""
return self.properties.get("title", None)
@property
def details(self):
"""Additional details about the task."""
return self.properties.get(
"details",
PlannerTaskDetails(
self.context, ResourcePath("details", self.resource_path)
),
)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
context: The context object required by the parent Entity class, typically containing authentication and connection information for Microsoft 365 API calls
resource_path: The ResourcePath object that defines the API endpoint path for this specific task resource within the Microsoft 365 Graph API hierarchy
Return Value
Instantiation returns a PlannerTask object that represents a specific task in Microsoft 365 Planner. The object provides access to task properties through read-only properties. The 'title' property returns a string or None, and the 'details' property returns a PlannerTaskDetails object that provides access to additional task information.
Class Interface
Methods
@property title(self) -> Optional[str]
property
Purpose: Returns the title of the Planner task
Returns: A string containing the task title, or None if the title is not set
@property details(self) -> PlannerTaskDetails
property
Purpose: Returns the detailed information object for the task, providing access to additional task properties
Returns: A PlannerTaskDetails object containing additional details about the task. If not already loaded, creates a new instance with the appropriate resource path
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
properties |
dict | Inherited from Entity base class. Dictionary storing the task's property values retrieved from the Microsoft Graph API | instance |
context |
ClientContext | Inherited from Entity base class. The context object containing authentication and connection information for API calls | instance |
resource_path |
ResourcePath | Inherited from Entity base class. The resource path defining the API endpoint for this task entity | instance |
Dependencies
office365
Required Imports
from office365.entity import Entity
from office365.planner.tasks.task_details import PlannerTaskDetails
from office365.runtime.paths.resource_path import ResourcePath
Usage Example
# Assuming you have a configured context and resource_path
from office365.planner.tasks.planner_task import PlannerTask
from office365.runtime.paths.resource_path import ResourcePath
# Instantiate a PlannerTask (typically done internally by the SDK)
task = PlannerTask(context, ResourcePath('tasks', parent_path))
# Access task properties
task_title = task.title # Get the task title
print(f"Task Title: {task_title}")
# Access detailed task information
task_details = task.details # Returns PlannerTaskDetails object
# The details object provides additional task information
# Note: In practice, PlannerTask objects are usually obtained through
# queries or collections rather than direct instantiation:
# tasks = plan.tasks.get().execute_query()
# for task in tasks:
# print(task.title)
Best Practices
- Do not instantiate PlannerTask directly; obtain instances through the Office 365 SDK's query methods or collections
- The class uses lazy loading for the details property - the PlannerTaskDetails object is only created when accessed
- Properties are read-only; use appropriate SDK methods to modify task data
- Ensure proper authentication context is established before accessing task properties
- The title property may return None if not set, so check for None before using the value
- This class inherits from Entity, so it has access to all Entity base class methods and properties
- The details property creates a new PlannerTaskDetails instance with the correct resource path when first accessed
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class PlannerTaskDetails 83.2% similar
-
class PlannerPlan 75.6% similar
-
class Planner 74.8% similar
-
class PlannerBucket 74.5% similar
-
class PlannerPlanDetails 72.7% similar