Skip to content

Commit 930876e

Browse files
committed
Outlook enhancements: new types & methods
1 parent 0b67bbb commit 930876e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+534
-137
lines changed

examples/outlook/send_message_with_large_attachment.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ def run_example_1():
1919
body="The new cafeteria is open.",
2020
to_recipients=["[email protected]"]
2121
).execute_query()
22+
print(draft_message.id)
2223

2324
draft_message.upload_attachment(local_path, print_progress).send().execute_query()
24-
print(draft_message.id)
2525

2626

2727
def run_example_2():
2828
message = client.me.messages.add(
2929
subject="Meet for lunch?",
3030
body="The new cafeteria is open.",
31-
to_recipients=["[email protected]"]
31+
3232
).upload_attachment(local_path, print_progress).execute_query()
3333
print(message.id)
3434

3535

36-
run_example_1()
37-
#run_example_2()
36+
#run_example_1()
37+
run_example_2()
3838

3939

examples/teams/send_message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22

33
from office365.graph_client import GraphClient
4-
from office365.outlook.mail.itemBody import ItemBody
4+
from office365.outlook.mail.item_body import ItemBody
55
from tests.graph_case import acquire_token_by_username_password
66

77
client = GraphClient(acquire_token_by_username_password)

generator/metadata/SharePoint.xml

Lines changed: 303 additions & 14 deletions
Large diffs are not rendered by default.

office365/communications/onlinemeetings/online_meeting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from office365.communications.onlinemeetings.meeting_participants import MeetingParticipants
22
from office365.entity import Entity
3-
from office365.outlook.mail.itemBody import ItemBody
3+
from office365.outlook.mail.item_body import ItemBody
44

55

66
class OnlineMeeting(Entity):

office365/directory/groups/group.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from office365.delta_collection import DeltaCollection
44
from office365.directory.applications.app_role_assignment import AppRoleAssignmentCollection
5+
from office365.directory.extensions.extension import Extension
56
from office365.directory.licenses.assigned_license import AssignedLicense
67
from office365.directory.object import DirectoryObject
78
from office365.directory.object_collection import DirectoryObjectCollection
@@ -10,6 +11,7 @@
1011
from office365.onedrive.drives.drive import Drive
1112
from office365.onenote.onenote import Onenote
1213
from office365.outlook.calendar.event import Event
14+
from office365.outlook.mail.conversation_thread import ConversationThread
1315
from office365.planner.group import PlannerGroup
1416
from office365.runtime.client_result import ClientResult
1517
from office365.runtime.client_value_collection import ClientValueCollection
@@ -121,10 +123,18 @@ def delete_object(self, permanent_delete=False):
121123
return self
122124

123125
@property
124-
def members(self):
125-
"""Users and groups that are members of this group.
126+
def extensions(self):
127+
"""
128+
The collection of open extensions defined for the group
129+
"""
130+
return self.properties.get('extensions',
131+
EntityCollection(self.context, Extension,
132+
ResourcePath("extensions", self.resource_path)))
126133

127-
:rtype: DirectoryObjectCollection
134+
@property
135+
def members(self):
136+
"""
137+
Users and groups that are members of this group.
128138
"""
129139
return self.properties.get('members',
130140
DirectoryObjectCollection(self.context, ResourcePath("members", self.resource_path)))
@@ -150,6 +160,13 @@ def transitive_member_of(self):
150160
DirectoryObjectCollection(self.context,
151161
ResourcePath("transitiveMemberOf", self.resource_path)))
152162

163+
@property
164+
def threads(self):
165+
"""The group's conversation threads"""
166+
return self.properties.get('threads',
167+
EntityCollection(self.context, ConversationThread,
168+
ResourcePath("threads", self.resource_path)))
169+
153170
@property
154171
def owners(self):
155172
"""The owners of the group.
@@ -207,6 +224,7 @@ def get_property(self, name, default_value=None):
207224
if default_value is None:
208225
property_mapping = {
209226
"appRoleAssignments": self.app_role_assignments,
227+
"assignedLicenses": self.assigned_licenses,
210228
"transitiveMembers": self.transitive_members,
211229
"transitiveMemberOf": self.transitive_member_of,
212230
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from office365.entity import Entity
2+
3+
4+
class OfficeGraphInsights(Entity):
5+
"""
6+
Insights are relationships calculated using advanced analytics and machine learning techniques.
7+
You can, for example, identify OneDrive for Business documents trending around users.
8+
"""

office365/directory/security/__init__.py

Whitespace-only changes.

office365/directory/users/user.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from office365.delta_collection import DeltaCollection
44
from office365.directory.authentication.authentication import Authentication
55
from office365.directory.extensions.extension import Extension
6+
from office365.directory.insights.office_graph import OfficeGraphInsights
67
from office365.directory.licenses.assigned_plan import AssignedPlan
78
from office365.directory.users.settings import UserSettings
89
from office365.onedrive.sites.site import Site
@@ -353,6 +354,12 @@ def followed_sites(self):
353354
EntityCollection(self.context, Site,
354355
ResourcePath("followedSites", self.resource_path)))
355356

357+
@property
358+
def insights(self):
359+
""""""
360+
return self.properties.get('insights',
361+
OfficeGraphInsights(self.context, ResourcePath("insights", self.resource_path)))
362+
356363
@property
357364
def photo(self):
358365
"""
@@ -364,7 +371,7 @@ def photo(self):
364371
@property
365372
def manager(self):
366373
"""
367-
The user or contact that is this user's manager. Read-only. (HTTP Methods: GET, PUT, DELETE.)
374+
The user or contact that is this user's manager
368375
"""
369376
return self.properties.get('manager',
370377
DirectoryObject(self.context, ResourcePath("manager", self.resource_path)))
@@ -557,7 +564,8 @@ def get_property(self, name, default_value=None):
557564
"assignedLicenses": self.assigned_licenses,
558565
"mailFolders": self.mail_folders,
559566
"mailboxSettings": self.mailbox_settings,
560-
"directReports": self.direct_reports
567+
"directReports": self.direct_reports,
568+
"onlineMeetings": self.online_meetings
561569
}
562570
default_value = property_mapping.get(name, None)
563571
return super(User, self).get_property(name, default_value)

office365/graph_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from office365.runtime.queries.delete_entity import DeleteEntityQuery
4242
from office365.runtime.queries.update_entity import UpdateEntityQuery
4343
from office365.search.entity import SearchEntity
44-
from office365.security.security import Security
44+
from office365.directory.security.security import Security
4545
from office365.teams.chats.collection import ChatCollection
4646
from office365.teams.collection import TeamCollection
4747
from office365.teams.template import TeamsTemplate

office365/onedrive/contenttypes/collection.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from office365.entity_collection import EntityCollection
22
from office365.onedrive.contenttypes.content_type import ContentType
3-
from office365.runtime.http.http_method import HttpMethod
43
from office365.runtime.queries.create_entity import CreateEntityQuery
4+
from office365.runtime.queries.function import FunctionQuery
55
from office365.runtime.queries.service_operation import ServiceOperationQuery
66

77

@@ -86,14 +86,7 @@ def get_compatible_hub_content_types(self):
8686
to sites and lists, effectively switching from a "push everywhere" to "pull as needed" approach.
8787
The method allows users to pull content types directly from the content type hub to a site or list.
8888
"""
89-
def _construct_request(request):
90-
"""
91-
:type request: office365.runtime.http.request_options.RequestOptions
92-
"""
93-
request.method = HttpMethod.Get
94-
9589
return_type = ContentTypeCollection(self.context, self.resource_path)
96-
qry = ServiceOperationQuery(self, "getCompatibleHubContentTypes", None, None, None, return_type)
90+
qry = FunctionQuery(self, "getCompatibleHubContentTypes", None, return_type)
9791
self.context.add_query(qry)
98-
self.context.before_execute(_construct_request)
9992
return return_type

office365/onedrive/contenttypes/content_type.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from office365.onedrive.listitems.item_reference import ItemReference
99
from office365.runtime.client_result import ClientResult
1010
from office365.runtime.paths.resource_path import ResourcePath
11+
from office365.runtime.queries.function import FunctionQuery
1112
from office365.runtime.queries.service_operation import ServiceOperationQuery
1213
from office365.runtime.types.collections import StringCollection
1314

@@ -20,8 +21,8 @@ def is_published(self):
2021
"""
2122
Check the publishing status of a contentType in a content type hub site.
2223
"""
23-
return_type = ClientResult(self.context)
24-
qry = ServiceOperationQuery(self, "isPublished", None, None, None, return_type)
24+
return_type = ClientResult(self.context, bool())
25+
qry = FunctionQuery(self, "isPublished", None, return_type)
2526
self.context.add_query(qry)
2627
return return_type
2728

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from office365.runtime.client_result import ClientResult
2-
from office365.runtime.http.http_method import HttpMethod
2+
from office365.runtime.queries.function import FunctionQuery
33
from office365.runtime.queries.service_operation import ServiceOperationQuery
44

55

@@ -12,15 +12,7 @@ def create_download_content_query(file_item, format_name=None):
1212
action_name = "content"
1313
if format_name is not None:
1414
action_name = action_name + r"?format={0}".format(format_name)
15-
qry = ServiceOperationQuery(file_item, action_name, None, None, None, return_type)
16-
17-
def _construct_query(request):
18-
"""
19-
:type request: office365.runtime.http.request_options.RequestOptions
20-
"""
21-
request.method = HttpMethod.Get
22-
file_item.context.before_execute(_construct_query)
23-
return qry
15+
return FunctionQuery(file_item, action_name, None, return_type)
2416

2517

2618
def create_download_session_content_query(file_item, format_name=None):
@@ -31,5 +23,4 @@ def create_download_session_content_query(file_item, format_name=None):
3123
action_name = "content"
3224
if format_name is not None:
3325
action_name = action_name + r"?format={0}".format(format_name)
34-
qry = ServiceOperationQuery(file_item, action_name)
35-
return qry
26+
return ServiceOperationQuery(file_item, action_name)

office365/onenote/pages/page.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from office365.onenote.pages.page_links import PageLinks
44
from office365.onenote.sections.section import OnenoteSection
55
from office365.runtime.client_result import ClientResult
6-
from office365.runtime.http.http_method import HttpMethod
7-
from office365.runtime.queries.service_operation import ServiceOperationQuery
6+
from office365.runtime.queries.function import FunctionQuery
87
from office365.runtime.paths.resource_path import ResourcePath
98
from office365.runtime.types.collections import StringCollection
109

@@ -14,18 +13,10 @@ class OnenotePage(OnenoteEntitySchemaObjectModel):
1413

1514
def get_content(self):
1615
"""Download the page's HTML content. """
17-
result = ClientResult(self.context)
18-
qry = ServiceOperationQuery(self, "content", None, None, None, result)
19-
20-
def _construct_query(request):
21-
"""
22-
:type request: office365.runtime.http.request_options.RequestOptions
23-
"""
24-
request.method = HttpMethod.Get
25-
26-
self.context.before_execute(_construct_query)
16+
return_type = ClientResult(self.context)
17+
qry = FunctionQuery(self, "content", None, return_type)
2718
self.context.add_query(qry)
28-
return result
19+
return return_type
2920

3021
@property
3122
def content_url(self):
@@ -60,20 +51,16 @@ def user_tags(self):
6051
@property
6152
def parent_notebook(self):
6253
"""The notebook that contains the page. Read-only.
63-
64-
:rtype: Notebook
6554
"""
66-
return self.get_property('parentNotebook',
67-
Notebook(self.context, ResourcePath("parentNotebook", self.resource_path)))
55+
return self.properties.get('parentNotebook',
56+
Notebook(self.context, ResourcePath("parentNotebook", self.resource_path)))
6857

6958
@property
7059
def parent_section(self):
71-
"""The section that contains the page. Read-only.
72-
73-
:rtype: OnenoteSection
60+
"""The section that contains the page.
7461
"""
75-
return self.get_property('parentSection',
76-
OnenoteSection(self.context, ResourcePath("parentSection", self.resource_path)))
62+
return self.properties.get('parentSection',
63+
OnenoteSection(self.context, ResourcePath("parentSection", self.resource_path)))
7764

7865
def get_property(self, name, default_value=None):
7966
if default_value is None:

office365/outlook/calendar/calendar.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ def get_schedule(self, schedules, start_time=None, end_time=None, availability_v
3535
"endTime": DateTimeTimeZone.parse(end_time),
3636
"availabilityViewInterval": availability_view_interval
3737
}
38-
result = ClientResult(self.context, ClientValueCollection(ScheduleInformation))
39-
qry = ServiceOperationQuery(self, "getSchedule", None, payload, None, result)
38+
return_type = ClientResult(self.context, ClientValueCollection(ScheduleInformation))
39+
qry = ServiceOperationQuery(self, "getSchedule", None, payload, None, return_type)
4040
self.context.add_query(qry)
41-
return result
41+
return return_type
4242

4343
@property
4444
def can_edit(self):

office365/outlook/calendar/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from office365.outlook.calendar.email_address import EmailAddress
77
from office365.outlook.item import OutlookItem
88
from office365.outlook.mail.attachments.collection import AttachmentCollection
9-
from office365.outlook.mail.itemBody import ItemBody
9+
from office365.outlook.mail.item_body import ItemBody
1010
from office365.outlook.mail.location import Location
1111
from office365.runtime.client_value_collection import ClientValueCollection
1212
from office365.runtime.queries.service_operation import ServiceOperationQuery

office365/outlook/mail/attachments/attachment.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from office365.entity import Entity
22
from office365.runtime.client_result import ClientResult
3-
from office365.runtime.http.http_method import HttpMethod
4-
from office365.runtime.queries.service_operation import ServiceOperationQuery
3+
from office365.runtime.queries.function import FunctionQuery
54

65

76
class Attachment(Entity):
@@ -28,18 +27,10 @@ def get_content(self):
2827
"""
2928
Gets the raw contents of a file or item attachment
3029
"""
31-
result = ClientResult(self.context)
32-
qry = ServiceOperationQuery(self, "$value", None, None, None, result)
33-
34-
def _construct_query(request):
35-
"""
36-
:type request: office365.runtime.http.request_options.RequestOptions
37-
"""
38-
request.method = HttpMethod.Get
39-
40-
self.context.before_execute(_construct_query)
30+
return_type = ClientResult(self.context)
31+
qry = FunctionQuery(self, "$value", None, return_type)
4132
self.context.add_query(qry)
42-
return result
33+
return return_type
4334

4435
@property
4536
def name(self):
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
from office365.outlook.mail.attachments.attachment import Attachment
2+
from office365.runtime.paths.resource_path import ResourcePath
23

34

45
class ItemAttachment(Attachment):
5-
pass
6+
"""A contact, event, or message that's attached to a user event, message, or post."""
7+
8+
@property
9+
def item(self):
10+
"""The attached message or event."""
11+
from office365.outlook.item import OutlookItem
12+
return self.properties.get('item',
13+
OutlookItem(self.context, ResourcePath("item", self.resource_path)))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from office365.entity import Entity
2+
from office365.entity_collection import EntityCollection
3+
from office365.outlook.mail.post import Post
4+
from office365.runtime.paths.resource_path import ResourcePath
5+
6+
7+
class ConversationThread(Entity):
8+
"""A conversationThread is a collection of posts."""
9+
10+
@property
11+
def posts(self):
12+
return self.properties.get('posts',
13+
EntityCollection(self.context, Post, ResourcePath("posts", self.resource_path)))

office365/outlook/mail/folder.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MultiValueLegacyExtendedProperty
33
from office365.entity import Entity
44
from office365.entity_collection import EntityCollection
5-
from office365.outlook.mail.messages.message import Message
5+
from office365.outlook.mail.messages.collection import MessageCollection
66
from office365.outlook.mail.messages.message_rule import MessageRule
77
from office365.runtime.paths.resource_path import ResourcePath
88

@@ -42,8 +42,7 @@ def message_rules(self):
4242
def messages(self):
4343
"""The collection of messages in the mailFolder."""
4444
return self.properties.get('messages',
45-
EntityCollection(self.context, Message,
46-
ResourcePath("messages", self.resource_path)))
45+
MessageCollection(self.context, ResourcePath("messages", self.resource_path)))
4746

4847
@property
4948
def multi_value_extended_properties(self):

0 commit comments

Comments
 (0)