Skip to content

Commit b59e027

Browse files
committed
planner & todo new types and methods
1 parent fc2705d commit b59e027

File tree

25 files changed

+314
-20
lines changed

25 files changed

+314
-20
lines changed

examples/onedrive/files/get_permissions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
file_item = client.me.drive.root.get_by_path(file_path)
1515
permissions = file_item.permissions.get().execute_query()
1616
for perm in permissions:
17-
print(perm.granted_to_v2)
17+
print(perm.granted_to_v2)

examples/planner/create_task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
plans = group.planner.plans.get().execute_query()
1616
if len(plans) == 0:
1717
sys.exit("No plans were found")
18-
task = plans[0].tasks.add(title="New task").execute_query()
18+
task = client.planner.tasks.add("Update client list", plans[0]).execute_query()
1919
print("Task {0} has been created".format(task.title))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class FileSecurityState(ClientValue):
5+
"""Contains information about the file (not process) related to the alert."""

office365/onedrive/workbooks/charts/title.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class WorkbookChartTitle(Entity):
88

99
@property
1010
def format(self):
11-
""" The formatting of a chart title, which includes fill and font formatting."""
11+
"""The formatting of a chart title, which includes fill and font formatting."""
1212
return self.properties.get(
1313
"format",
1414
WorkbookChartTitleFormat(
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class PlannerCategoryDescriptions(ClientValue):
5+
"""Represents the descriptive labels for the categories that have been defined for a plan.
6+
It belongs to the plan details object. There can be up to 25 categories defined."""
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class PlannerExternalReferences(ClientValue):
5+
"""The plannerExternalReferences resource represents the collection of references on a task. This is an Open Type.
6+
It's part of the task details object. The value in the property-value pair is the externalReference object.
7+
"""

office365/planner/planner.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from office365.entity_collection import EntityCollection
33
from office365.planner.buckets.bucket import PlannerBucket
44
from office365.planner.plans.collection import PlannerPlanCollection
5-
from office365.planner.tasks.task import PlannerTask
5+
from office365.planner.tasks.collection import PlannerTaskCollection
66
from office365.runtime.paths.resource_path import ResourcePath
77

88

@@ -25,12 +25,12 @@ def buckets(self):
2525

2626
@property
2727
def tasks(self):
28-
# type: () -> EntityCollection[PlannerTask]
28+
# type: () -> PlannerTaskCollection
2929
"""Returns the plannerTasks assigned to the user."""
3030
return self.properties.get(
3131
"tasks",
32-
EntityCollection(
33-
self.context, PlannerTask, ResourcePath("tasks", self.resource_path)
32+
PlannerTaskCollection(
33+
self.context, ResourcePath("tasks", self.resource_path)
3434
),
3535
)
3636

office365/planner/plans/container.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,15 @@ class PlannerPlanContainer(ClientValue):
99
the contained plans are also deleted. The properties of the plannerPlanContainer cannot be changed after the plan
1010
is created.
1111
"""
12+
13+
def __init__(self, container_id=None, type_=None, url=None):
14+
"""
15+
:param str container_id: The identifier of the resource that contains the plan
16+
:param str type_: The type of the resource that contains the plan. For supported types, see the previous
17+
table. Possible values are: group, unknownFutureValue, roster. Use the Prefer: include-unknown-enum-members
18+
request header to get the following value in this evolvable enum: roster.
19+
:param str url: The full canonical URL of the container.
20+
"""
21+
self.containerId = container_id
22+
self.type = type_
23+
self.url = url

office365/planner/plans/details.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
11
from office365.entity import Entity
2+
from office365.planner.category_descriptions import PlannerCategoryDescriptions
3+
from office365.planner.user_ids import PlannerUserIds
24

35

46
class PlannerPlanDetails(Entity):
57
"""
68
The plannerPlanDetails resource represents the additional information about a plan.
79
Each plan object has a details object.
810
"""
11+
12+
@property
13+
def category_descriptions(self):
14+
# type: () -> PlannerCategoryDescriptions
15+
"""
16+
An object that specifies the descriptions of the 25 categories that can be associated with tasks in the plan.
17+
"""
18+
return self.properties.get(
19+
"categoryDescriptions", PlannerCategoryDescriptions()
20+
)
21+
22+
@property
23+
def shared_with(self):
24+
# type: () -> PlannerUserIds
25+
"""
26+
Set of user IDs that this plan is shared with. If you're using Microsoft 365 groups, use the Groups
27+
API to manage group membership to share the group's plan. You can also add existing members of the group to
28+
this collection, although it isn't required for them to access the plan owned by the group.
29+
"""
30+
return self.properties.get("sharedWith", PlannerUserIds())
31+
32+
def get_property(self, name, default_value=None):
33+
if default_value is None:
34+
property_mapping = {
35+
"categoryDescriptions": self.category_descriptions,
36+
"sharedWith": self.shared_with,
37+
}
38+
default_value = property_mapping.get(name, None)
39+
return super(PlannerPlanDetails, self).get_property(name, default_value)

office365/planner/tasks/collection.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from office365.entity_collection import EntityCollection
2+
from office365.planner.plans.plan import PlannerPlan
3+
from office365.planner.tasks.task import PlannerTask
4+
from office365.runtime.queries.create_entity import CreateEntityQuery
5+
6+
7+
class PlannerTaskCollection(EntityCollection[PlannerTask]):
8+
def __init__(self, context, resource_path=None):
9+
super(PlannerTaskCollection, self).__init__(context, PlannerTask, resource_path)
10+
11+
def add(self, title, plan, bucket=None):
12+
"""
13+
Create a new plannerTask.
14+
15+
:param str title: Task title
16+
:param str|PlannerPlan plan: Plan identifier or Plan object
17+
:param str|PlannerBucket bucket: Bucket identifier or Plan object
18+
"""
19+
return_type = PlannerTask(self.context)
20+
self.add_child(return_type)
21+
22+
def _add(plan_id):
23+
# type: (str) -> None
24+
payload = {"title": title, "planId": plan_id, "bucketId": bucket}
25+
qry = CreateEntityQuery(self, payload, return_type)
26+
self.context.add_query(qry)
27+
28+
if isinstance(plan, PlannerPlan):
29+
30+
def _parent_loaded():
31+
_add(plan.id)
32+
33+
plan.ensure_property("id", _parent_loaded)
34+
else:
35+
_add(plan)
36+
37+
return return_type

0 commit comments

Comments
 (0)