Office365-REST-Python-Client 2.5.1__py3-none-any.whl → 2.5.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/METADATA +6 -6
- {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/RECORD +265 -259
- office365/base_item.py +12 -20
- office365/communications/onlinemeetings/collection.py +1 -1
- office365/communications/onlinemeetings/online_meeting.py +20 -35
- office365/communications/presences/presence.py +18 -7
- office365/delta_collection.py +10 -1
- office365/delta_path.py +1 -1
- office365/directory/administrative_unit.py +6 -7
- office365/directory/applications/application.py +24 -18
- office365/directory/applications/roles/assignment.py +13 -1
- office365/directory/applications/roles/collection.py +13 -0
- office365/directory/applications/roles/role.py +6 -1
- office365/directory/audit/directory.py +8 -7
- office365/directory/audit/log_root.py +3 -0
- office365/directory/audit/signins/signin.py +19 -29
- office365/directory/authentication/authentication.py +1 -0
- office365/directory/authentication/methods/details.py +8 -6
- office365/directory/authentication/methods/phone.py +3 -1
- office365/directory/extensions/extension_property.py +7 -9
- office365/directory/groups/collection.py +10 -3
- office365/directory/groups/group.py +19 -19
- office365/directory/groups/lifecycle_policy.py +8 -7
- office365/directory/identities/provider.py +5 -6
- office365/directory/insights/usage_details.py +8 -3
- office365/directory/internal/paths/me.py +1 -1
- office365/directory/invitations/collection.py +1 -1
- office365/directory/invitations/invitation.py +6 -6
- office365/directory/object_collection.py +2 -3
- office365/directory/permissions/email_identity.py +7 -0
- office365/directory/permissions/grants/resource_specific.py +10 -9
- office365/directory/permissions/identity.py +3 -0
- office365/directory/permissions/identity_set.py +3 -0
- office365/directory/policies/base.py +4 -4
- office365/directory/policies/root.py +6 -4
- office365/directory/protection/information.py +3 -3
- office365/directory/rolemanagement/application.py +2 -0
- office365/directory/rolemanagement/role.py +11 -10
- office365/directory/rolemanagement/template.py +9 -8
- office365/directory/rolemanagement/unified_role_assignment.py +5 -4
- office365/directory/rolemanagement/unified_role_definition.py +6 -4
- office365/directory/security/security.py +3 -0
- office365/directory/serviceprincipals/collection.py +20 -4
- office365/directory/serviceprincipals/service_principal.py +79 -12
- office365/directory/users/activities/activity.py +5 -4
- office365/directory/users/user.py +29 -34
- office365/entity.py +2 -2
- office365/entity_collection.py +12 -5
- office365/graph_client.py +90 -8
- office365/intune/audit/event.py +4 -3
- office365/intune/devices/enrollment/configuration.py +6 -4
- office365/intune/devices/managed.py +9 -12
- office365/onedrive/analytics/item_activity_stat.py +4 -3
- office365/onedrive/columns/column_link.py +4 -4
- office365/onedrive/columns/definition.py +29 -32
- office365/onedrive/columns/definition_collection.py +1 -1
- office365/onedrive/contenttypes/content_type.py +16 -18
- office365/onedrive/documentsets/version.py +7 -3
- office365/onedrive/driveitems/driveItem.py +48 -49
- office365/onedrive/drives/drive.py +7 -2
- office365/onedrive/internal/paths/children.py +2 -2
- office365/onedrive/internal/paths/root.py +1 -1
- office365/onedrive/internal/paths/shared.py +1 -1
- office365/onedrive/internal/paths/site.py +3 -3
- office365/onedrive/internal/paths/url.py +2 -2
- office365/onedrive/listitems/list_item.py +2 -0
- office365/onedrive/lists/list.py +7 -4
- office365/onedrive/permissions/collection.py +28 -7
- office365/onedrive/permissions/permission.py +5 -7
- office365/onedrive/permissions/sharing_link.py +1 -1
- office365/onedrive/sharepoint.py +1 -0
- office365/onedrive/shares/collection.py +2 -5
- office365/onedrive/shares/drive_item.py +4 -0
- office365/onedrive/sites/site.py +6 -0
- office365/onedrive/termstore/groups/collection.py +3 -8
- office365/onedrive/termstore/groups/group.py +8 -0
- office365/onedrive/termstore/sets/collection.py +2 -6
- office365/onedrive/termstore/sets/name.py +5 -0
- office365/onedrive/termstore/sets/set.py +7 -0
- office365/onedrive/termstore/store.py +10 -13
- office365/onedrive/versions/drive_item.py +3 -1
- office365/onedrive/workbooks/ranges/range.py +9 -13
- office365/onedrive/workbooks/ranges/view.py +1 -0
- office365/onedrive/workbooks/tables/rows/row.py +3 -0
- office365/onedrive/workbooks/tables/table.py +7 -4
- office365/onedrive/workbooks/worksheets/worksheet.py +12 -4
- office365/onenote/entity_hierarchy_model.py +4 -0
- office365/onenote/internal/multipart_page_query.py +4 -5
- office365/onenote/notebooks/notebook.py +4 -0
- office365/onenote/pages/collection.py +3 -2
- office365/onenote/resources/resource.py +5 -4
- office365/onenote/sectiongroups/section_group.py +10 -7
- office365/onenote/sections/section.py +1 -1
- office365/outlook/calendar/attendees/base.py +2 -1
- office365/outlook/calendar/calendar.py +18 -10
- office365/outlook/calendar/events/collection.py +0 -2
- office365/outlook/calendar/group.py +7 -8
- office365/outlook/calendar/meetingtimes/suggestion.py +8 -4
- office365/outlook/calendar/meetingtimes/time_slot.py +3 -0
- office365/outlook/calendar/permissions/collection.py +1 -1
- office365/outlook/calendar/rooms/__init__.py +0 -0
- office365/outlook/calendar/rooms/list.py +27 -0
- office365/outlook/calendar/rooms/room.py +8 -0
- office365/outlook/calendar/schedule/information.py +0 -1
- office365/outlook/contacts/collection.py +0 -8
- office365/outlook/contacts/contact.py +14 -14
- office365/outlook/contacts/folder.py +3 -0
- office365/outlook/mail/attachments/attachment.py +31 -31
- office365/outlook/mail/attachments/collection.py +34 -6
- office365/outlook/mail/conversation.py +6 -4
- office365/outlook/mail/folders/collection.py +0 -7
- office365/outlook/mail/folders/folder.py +50 -18
- office365/outlook/mail/messages/collection.py +0 -1
- office365/outlook/mail/messages/message.py +58 -68
- office365/outlook/mail/physical_address.py +11 -5
- office365/outlook/mail/recipient.py +3 -1
- office365/outlook/mail/recurrence_range.py +14 -6
- office365/outlook/user.py +1 -0
- office365/planner/planner.py +9 -12
- office365/planner/plans/collection.py +17 -18
- office365/planner/plans/container.py +11 -0
- office365/planner/plans/plan.py +21 -10
- office365/runtime/auth/authentication_context.py +3 -3
- office365/runtime/auth/providers/acs_token_provider.py +7 -9
- office365/runtime/auth/providers/saml_token_provider.py +5 -2
- office365/runtime/client_object.py +6 -15
- office365/runtime/client_object_collection.py +36 -35
- office365/runtime/client_result.py +6 -7
- office365/runtime/client_runtime_context.py +10 -16
- office365/runtime/client_value_collection.py +3 -10
- office365/runtime/compat.py +2 -0
- office365/runtime/odata/query_options.py +1 -3
- office365/runtime/odata/reader.py +1 -1
- office365/runtime/odata/request.py +2 -4
- office365/runtime/odata/type.py +17 -0
- office365/runtime/odata/v4/upload_session_request.py +27 -30
- office365/runtime/paths/appid.py +1 -1
- office365/runtime/{odata/url_builder.py → paths/builder.py} +24 -9
- office365/runtime/paths/item.py +3 -1
- office365/runtime/paths/resource_path.py +12 -16
- office365/runtime/paths/service_operation.py +8 -7
- office365/runtime/paths/v3/__init__.py +0 -0
- office365/runtime/paths/{key.py → v3/entity.py} +5 -5
- office365/runtime/paths/v4/__init__.py +0 -0
- office365/runtime/paths/{entity.py → v4/entity.py} +13 -11
- office365/runtime/queries/function.py +1 -1
- office365/runtime/types/event_handler.py +1 -3
- office365/search/entity.py +15 -8
- office365/search/external/external.py +1 -0
- office365/search/sort_property.py +3 -0
- office365/sharepoint/attachments/attachment.py +3 -1
- office365/sharepoint/attachments/collection.py +3 -0
- office365/sharepoint/changes/change.py +12 -1
- office365/sharepoint/changes/collection.py +1 -1
- office365/sharepoint/changes/list.py +3 -0
- office365/sharepoint/changes/token.py +4 -0
- office365/sharepoint/changes/type.py +23 -23
- office365/sharepoint/changes/web.py +7 -3
- office365/sharepoint/client_context.py +21 -18
- office365/sharepoint/clientsidecomponent/hostedapps/manager.py +3 -3
- office365/sharepoint/contenttypes/content_type.py +47 -56
- office365/sharepoint/contenttypes/content_type_id.py +1 -1
- office365/sharepoint/documentmanagement/document_id.py +2 -2
- office365/sharepoint/documentmanagement/document_set.py +6 -7
- office365/sharepoint/entity_collection.py +9 -0
- office365/sharepoint/features/feature.py +6 -8
- office365/sharepoint/fields/collection.py +6 -5
- office365/sharepoint/fields/field.py +28 -46
- office365/sharepoint/fields/related_field_collection.py +1 -1
- office365/sharepoint/fields/user_value.py +3 -3
- office365/sharepoint/files/checked_out_file.py +4 -2
- office365/sharepoint/files/checked_out_file_collection.py +1 -1
- office365/sharepoint/files/collection.py +84 -14
- office365/sharepoint/files/file.py +118 -110
- office365/sharepoint/files/versions/collection.py +5 -3
- office365/sharepoint/files/versions/event.py +6 -3
- office365/sharepoint/files/versions/version.py +31 -18
- office365/sharepoint/folders/collection.py +5 -10
- office365/sharepoint/folders/folder.py +41 -24
- office365/sharepoint/forms/collection.py +1 -1
- office365/sharepoint/forms/form.py +4 -4
- office365/sharepoint/internal/paths/static_operation.py +9 -0
- office365/sharepoint/internal/paths/web.py +20 -0
- office365/sharepoint/listitems/collection.py +4 -0
- office365/sharepoint/listitems/listitem.py +37 -38
- office365/sharepoint/listitems/versions/collection.py +1 -1
- office365/sharepoint/listitems/versions/version.py +18 -11
- office365/sharepoint/lists/collection.py +1 -2
- office365/sharepoint/lists/list.py +106 -153
- office365/sharepoint/marketplace/app_metadata_collection.py +3 -1
- office365/sharepoint/navigation/node.py +16 -15
- office365/sharepoint/navigation/node_collection.py +9 -3
- office365/sharepoint/permissions/base_permissions.py +11 -6
- office365/sharepoint/permissions/roles/assignments/collection.py +8 -12
- office365/sharepoint/permissions/roles/definitions/definition.py +3 -1
- office365/sharepoint/permissions/securable_object.py +38 -31
- office365/sharepoint/portal/groups/service.py +12 -16
- office365/sharepoint/portal/groups/site_manager.py +0 -1
- office365/sharepoint/principal/groups/group.py +24 -30
- office365/sharepoint/principal/principal.py +21 -19
- office365/sharepoint/principal/users/collection.py +5 -0
- office365/sharepoint/principal/users/user.py +20 -26
- office365/sharepoint/publishing/pages/collection.py +1 -4
- office365/sharepoint/publishing/pages/metadata.py +38 -51
- office365/sharepoint/publishing/pages/metadata_collection.py +5 -2
- office365/sharepoint/publishing/pages/page.py +12 -21
- office365/sharepoint/publishing/pages/reposts/repost.py +5 -9
- office365/sharepoint/publishing/pages/service.py +36 -49
- office365/sharepoint/pushnotifications/collection.py +3 -1
- office365/sharepoint/recyclebin/item.py +11 -9
- office365/sharepoint/recyclebin/item_collection.py +1 -1
- office365/sharepoint/search/service.py +8 -6
- office365/sharepoint/sharing/links/info.py +5 -2
- office365/sharepoint/sharing/links/share_response.py +3 -0
- office365/sharepoint/sharing/links/share_settings.py +3 -0
- office365/sharepoint/sharing/object_sharing_information.py +25 -19
- office365/sharepoint/sharing/object_sharing_information_user.py +10 -19
- office365/sharepoint/sharing/result.py +18 -41
- office365/sharepoint/sharing/role.py +20 -0
- office365/sharepoint/sharing/role_type.py +1 -0
- office365/sharepoint/sharing/user_sharing_result.py +12 -0
- office365/sharepoint/sites/language.py +6 -0
- office365/sharepoint/sites/language_collection.py +3 -0
- office365/sharepoint/sites/site.py +65 -86
- office365/sharepoint/storagemetrics/storage_metrics.py +5 -6
- office365/sharepoint/taxonomy/item.py +11 -10
- office365/sharepoint/taxonomy/stores/store.py +8 -8
- office365/sharepoint/taxonomy/terms/label.py +3 -0
- office365/sharepoint/taxonomy/terms/term.py +31 -0
- office365/sharepoint/tenant/administration/collaboration/insights_overview.py +10 -0
- office365/sharepoint/tenant/administration/hubsites/collection.py +1 -2
- office365/sharepoint/tenant/administration/hubsites/hub_site.py +20 -24
- office365/sharepoint/tenant/administration/internal/permission_grant.py +7 -0
- office365/sharepoint/tenant/administration/sites/properties.py +55 -44
- office365/sharepoint/tenant/administration/tenant.py +69 -69
- office365/sharepoint/types/resource_path.py +2 -2
- office365/sharepoint/ui/applicationpages/peoplepicker/query_parameters.py +1 -1
- office365/sharepoint/usercustomactions/collection.py +1 -2
- office365/sharepoint/userprofiles/my_site_links.py +4 -4
- office365/sharepoint/userprofiles/people_manager.py +1 -3
- office365/sharepoint/userprofiles/user_profile.py +9 -11
- office365/sharepoint/utilities/principal_info.py +12 -0
- office365/sharepoint/viva/employee_engagement.py +1 -1
- office365/sharepoint/webparts/definition_collection.py +1 -1
- office365/sharepoint/webs/collection.py +8 -0
- office365/sharepoint/webs/template_collection.py +3 -5
- office365/sharepoint/webs/web.py +75 -95
- office365/subscriptions/collection.py +1 -1
- office365/subscriptions/subscription.py +13 -11
- office365/teams/apps/app.py +1 -0
- office365/teams/channels/channel.py +1 -3
- office365/teams/collection.py +12 -16
- office365/teams/info.py +7 -4
- office365/teams/members/conversation_collection.py +1 -3
- office365/teams/operations/async_operation.py +3 -5
- office365/teams/schedule/groups/group.py +3 -0
- office365/teams/team.py +18 -20
- office365/todo/attachments/base.py +7 -9
- office365/todo/linked_resource.py +6 -6
- office365/todo/tasks/list.py +1 -0
- office365/todo/tasks/task.py +3 -0
- office365/onedrive/internal/queries/resumable_file_upload.py +0 -36
- office365/outlook/internal/queries/attachment_upload.py +0 -53
- office365/runtime/odata/path_builder.py +0 -23
- office365/sharepoint/internal/key_value.py +0 -28
- office365/sharepoint/internal/queries/create_file.py +0 -20
- office365/sharepoint/internal/queries/upload_session.py +0 -103
- {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/LICENSE +0 -0
- {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/WHEEL +0 -0
- {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/top_level.txt +0 -0
- /office365/planner/plans/{plan_details.py → details.py} +0 -0
|
@@ -63,9 +63,7 @@ class ODataRequest(ClientRequest):
|
|
|
63
63
|
return_type.set_property("__value", response.content)
|
|
64
64
|
else:
|
|
65
65
|
if isinstance(json_format, JsonLightFormat):
|
|
66
|
-
if isinstance(query, ServiceOperationQuery)
|
|
67
|
-
query, FunctionQuery
|
|
68
|
-
):
|
|
66
|
+
if isinstance(query, (ServiceOperationQuery, FunctionQuery)):
|
|
69
67
|
json_format.function = query.name
|
|
70
68
|
|
|
71
69
|
self.map_json(response.json(), return_type, json_format)
|
|
@@ -129,7 +127,7 @@ class ODataRequest(ClientRequest):
|
|
|
129
127
|
|
|
130
128
|
def _normalize_payload(payload):
|
|
131
129
|
# type: (ClientObject|ClientValue|dict|list) -> dict|list
|
|
132
|
-
if isinstance(payload, ClientObject
|
|
130
|
+
if isinstance(payload, (ClientObject, ClientValue)):
|
|
133
131
|
return payload.to_json(self._default_json_format)
|
|
134
132
|
elif isinstance(payload, dict):
|
|
135
133
|
return {
|
office365/runtime/odata/type.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import datetime
|
|
2
|
+
import inspect
|
|
2
3
|
import uuid
|
|
4
|
+
from typing import Type
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
class ODataType(object):
|
|
@@ -60,6 +62,11 @@ class ODataType(object):
|
|
|
60
62
|
:param str value: Represents date and time with values ranging from 12:00:00 midnight, January 1, 1753 A.D.
|
|
61
63
|
through 11:59:59 P.M, December 9999 A.D.
|
|
62
64
|
"""
|
|
65
|
+
if value is None:
|
|
66
|
+
return None
|
|
67
|
+
elif isinstance(value, datetime.datetime):
|
|
68
|
+
return value
|
|
69
|
+
|
|
63
70
|
known_formats = [
|
|
64
71
|
"%Y-%m-%dT%H:%M:%SZ",
|
|
65
72
|
"%Y-%m-%dT%H:%M:%S.%fZ",
|
|
@@ -90,6 +97,16 @@ class ODataType(object):
|
|
|
90
97
|
else:
|
|
91
98
|
return ODataType.primitive_types.get(client_type, None)
|
|
92
99
|
|
|
100
|
+
@staticmethod
|
|
101
|
+
def resolve_enum_key(enum_type, value):
|
|
102
|
+
# type: (Type, int) -> str
|
|
103
|
+
return next(
|
|
104
|
+
iter(
|
|
105
|
+
[item[0] for item in inspect.getmembers(enum_type) if item[1] == value]
|
|
106
|
+
),
|
|
107
|
+
None,
|
|
108
|
+
)
|
|
109
|
+
|
|
93
110
|
def add_property(self, prop_schema):
|
|
94
111
|
"""
|
|
95
112
|
:type prop_schema: office365.runtime.odata.property.ODataProperty
|
|
@@ -1,62 +1,57 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import typing
|
|
3
|
+
from typing import Callable
|
|
4
|
+
|
|
5
|
+
import requests
|
|
6
|
+
from typing_extensions import Self
|
|
2
7
|
|
|
3
8
|
from office365.runtime.client_request import ClientRequest
|
|
4
9
|
from office365.runtime.http.http_method import HttpMethod
|
|
5
10
|
from office365.runtime.http.request_options import RequestOptions
|
|
11
|
+
from office365.runtime.queries.upload_session import UploadSessionQuery
|
|
6
12
|
|
|
7
13
|
|
|
8
14
|
class UploadSessionRequest(ClientRequest):
|
|
9
15
|
def __init__(self, file_object, chunk_size, chunk_uploaded=None):
|
|
10
|
-
|
|
11
|
-
:type file_object: typing.IO
|
|
12
|
-
:type chunk_size: int
|
|
13
|
-
:type chunk_uploaded: (int) -> None
|
|
14
|
-
"""
|
|
16
|
+
# type: (typing.IO, int, Callable[[int], None]) -> None
|
|
15
17
|
super(UploadSessionRequest, self).__init__()
|
|
16
18
|
self._file_object = file_object
|
|
17
19
|
self._chunk_size = chunk_size
|
|
18
20
|
self._chunk_uploaded = chunk_uploaded
|
|
19
|
-
self.
|
|
20
|
-
self._range_end = 0
|
|
21
|
+
self._range_data = None
|
|
21
22
|
|
|
22
23
|
def build_request(self, query):
|
|
23
|
-
|
|
24
|
-
:type query: office365.runtime.queries.upload_session.UploadSessionQuery
|
|
25
|
-
"""
|
|
26
|
-
range_data = self._read_next()
|
|
24
|
+
# type: (UploadSessionQuery) -> Self
|
|
27
25
|
request = RequestOptions(query.upload_session_url)
|
|
28
26
|
request.method = HttpMethod.Put
|
|
29
|
-
request.set_header("Content-Length", str(len(
|
|
27
|
+
request.set_header("Content-Length", str(len(self._range_data)))
|
|
30
28
|
request.set_header(
|
|
31
29
|
"Content-Range",
|
|
32
30
|
"bytes {0}-{1}/{2}".format(
|
|
33
|
-
self.
|
|
31
|
+
self.range_start, self.range_end - 1, self.file_size
|
|
34
32
|
),
|
|
35
33
|
)
|
|
36
34
|
request.set_header("Accept", "*/*")
|
|
37
|
-
request.data =
|
|
35
|
+
request.data = self._range_data
|
|
38
36
|
return request
|
|
39
37
|
|
|
40
38
|
def process_response(self, response, query):
|
|
41
|
-
|
|
42
|
-
:type response: requests.Response
|
|
43
|
-
:type query: office365.runtime.queries.upload_session.UploadSessionQuery
|
|
44
|
-
"""
|
|
39
|
+
# type: (requests.Response, UploadSessionQuery) -> None
|
|
45
40
|
response.raise_for_status()
|
|
46
41
|
if callable(self._chunk_uploaded):
|
|
47
42
|
self._chunk_uploaded(self.range_end)
|
|
48
|
-
if self.has_pending_read:
|
|
49
|
-
self.execute_query(query)
|
|
50
43
|
|
|
51
|
-
def
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return content
|
|
44
|
+
def execute_query(self, query):
|
|
45
|
+
# type: (UploadSessionQuery) -> None
|
|
46
|
+
for self._range_data in self._read_next():
|
|
47
|
+
super(UploadSessionRequest, self).execute_query(query)
|
|
56
48
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
def _read_next(self):
|
|
50
|
+
while True:
|
|
51
|
+
content = self._file_object.read(self._chunk_size)
|
|
52
|
+
if not content:
|
|
53
|
+
break
|
|
54
|
+
yield content
|
|
60
55
|
|
|
61
56
|
@property
|
|
62
57
|
def file_size(self):
|
|
@@ -64,8 +59,10 @@ class UploadSessionRequest(ClientRequest):
|
|
|
64
59
|
|
|
65
60
|
@property
|
|
66
61
|
def range_start(self):
|
|
67
|
-
|
|
62
|
+
if self.range_end == 0:
|
|
63
|
+
return 0
|
|
64
|
+
return self.range_end - len(self._range_data)
|
|
68
65
|
|
|
69
66
|
@property
|
|
70
67
|
def range_end(self):
|
|
71
|
-
return self.
|
|
68
|
+
return self._file_object.tell()
|
office365/runtime/paths/appid.py
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
import json
|
|
2
|
+
import re
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
2
4
|
|
|
3
5
|
from office365.runtime.client_value import ClientValue
|
|
4
6
|
from office365.runtime.compat import is_string_type
|
|
7
|
+
from office365.runtime.paths.resource_path import ResourcePath
|
|
5
8
|
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from office365.runtime.paths.service_operation import ServiceOperationPath
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
|
|
13
|
+
class ODataPathBuilder(object):
|
|
8
14
|
@staticmethod
|
|
9
|
-
def
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
def parse_url(path_str):
|
|
16
|
+
# type: (str) -> ResourcePath
|
|
17
|
+
"""Parses path from a string"""
|
|
18
|
+
segments = [n for n in re.split(r"[('')]|/", path_str) if n]
|
|
19
|
+
if not segments:
|
|
20
|
+
raise TypeError("Invalid path")
|
|
21
|
+
path = None
|
|
22
|
+
for segment in segments:
|
|
23
|
+
path = ResourcePath(segment, path)
|
|
24
|
+
return path
|
|
12
25
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
@staticmethod
|
|
27
|
+
def build_segment(path):
|
|
28
|
+
# type: (ServiceOperationPath) -> str
|
|
29
|
+
"""Constructs url for path segment"""
|
|
30
|
+
url = path.name or ""
|
|
16
31
|
if isinstance(path.parameters, ClientValue):
|
|
17
32
|
url += "(@v)?@v={0}".format(json.dumps(path.parameters.to_json()))
|
|
18
33
|
elif path.parameters is not None:
|
|
@@ -20,7 +35,7 @@ class ODataUrlBuilder(object):
|
|
|
20
35
|
if isinstance(path.parameters, dict):
|
|
21
36
|
url += ",".join(
|
|
22
37
|
[
|
|
23
|
-
"%s=%s" % (key,
|
|
38
|
+
"%s=%s" % (key, ODataPathBuilder._encode_method_value(value))
|
|
24
39
|
for (key, value) in path.parameters.items()
|
|
25
40
|
if value is not None
|
|
26
41
|
]
|
|
@@ -28,7 +43,7 @@ class ODataUrlBuilder(object):
|
|
|
28
43
|
else:
|
|
29
44
|
url += ",".join(
|
|
30
45
|
[
|
|
31
|
-
"%s" % (
|
|
46
|
+
"%s" % (ODataPathBuilder._encode_method_value(value))
|
|
32
47
|
for (i, value) in enumerate(path.parameters)
|
|
33
48
|
if value is not None
|
|
34
49
|
]
|
office365/runtime/paths/item.py
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
from typing import Iterator
|
|
2
|
+
|
|
3
|
+
|
|
1
4
|
class ResourcePath(object):
|
|
2
5
|
"""OData resource path"""
|
|
3
6
|
|
|
4
|
-
def __init__(self, key, parent=None):
|
|
5
|
-
""
|
|
6
|
-
:type key: int or str
|
|
7
|
-
:type parent: ResourcePath or None
|
|
8
|
-
"""
|
|
7
|
+
def __init__(self, key=None, parent=None):
|
|
8
|
+
# type: (int|str, "ResourcePath") -> None
|
|
9
9
|
self._key = key
|
|
10
10
|
self._parent = parent
|
|
11
11
|
|
|
12
|
-
def patch(self, key
|
|
12
|
+
def patch(self, key):
|
|
13
|
+
if self._key is None:
|
|
14
|
+
self._key = key
|
|
13
15
|
return self
|
|
14
16
|
|
|
15
17
|
def __iter__(self):
|
|
18
|
+
# type: () -> Iterator["ResourcePath"]
|
|
16
19
|
current = self
|
|
17
20
|
while current:
|
|
18
21
|
yield current
|
|
@@ -25,11 +28,8 @@ class ResourcePath(object):
|
|
|
25
28
|
return self.to_url()
|
|
26
29
|
|
|
27
30
|
def to_url(self):
|
|
28
|
-
|
|
29
|
-
Builds url
|
|
30
|
-
|
|
31
|
-
:rtype: str
|
|
32
|
-
"""
|
|
31
|
+
# type: () -> str
|
|
32
|
+
"""Builds url"""
|
|
33
33
|
segments = []
|
|
34
34
|
for path in self:
|
|
35
35
|
segments.insert(0, path.segment)
|
|
@@ -43,11 +43,7 @@ class ResourcePath(object):
|
|
|
43
43
|
|
|
44
44
|
@property
|
|
45
45
|
def segment(self):
|
|
46
|
-
return str(self.
|
|
47
|
-
|
|
48
|
-
@property
|
|
49
|
-
def key(self):
|
|
50
|
-
return self._key
|
|
46
|
+
return str(self._key)
|
|
51
47
|
|
|
52
48
|
@property
|
|
53
49
|
def delimiter(self):
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from office365.runtime.
|
|
1
|
+
from office365.runtime.client_value import ClientValue
|
|
2
|
+
from office365.runtime.paths.builder import ODataPathBuilder
|
|
2
3
|
from office365.runtime.paths.resource_path import ResourcePath
|
|
3
4
|
|
|
4
5
|
|
|
@@ -6,17 +7,17 @@ class ServiceOperationPath(ResourcePath):
|
|
|
6
7
|
"""Path to address Service Operations which represents simple functions exposed by an OData service"""
|
|
7
8
|
|
|
8
9
|
def __init__(self, name, parameters=None, parent=None):
|
|
9
|
-
|
|
10
|
-
:type parameters: list or dict or office365.runtime.client_value.ClientValue or None
|
|
11
|
-
:type name: str
|
|
12
|
-
:type parent: office365.runtime.paths.resource_path.ResourcePath
|
|
13
|
-
"""
|
|
10
|
+
# type: (str, list|dict|ClientValue, ResourcePath) -> None
|
|
14
11
|
super(ServiceOperationPath, self).__init__(name, parent)
|
|
15
12
|
self._parameters = parameters
|
|
16
13
|
|
|
17
14
|
@property
|
|
18
15
|
def segment(self):
|
|
19
|
-
return
|
|
16
|
+
return ODataPathBuilder.build_segment(self)
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def name(self):
|
|
20
|
+
return self._key
|
|
20
21
|
|
|
21
22
|
@property
|
|
22
23
|
def parameters(self):
|
|
File without changes
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
from office365.runtime.paths.resource_path import ResourcePath
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
class
|
|
4
|
+
class EntityPath(ResourcePath):
|
|
5
5
|
"""Path for addressing a single entity by key"""
|
|
6
6
|
|
|
7
7
|
@property
|
|
8
8
|
def segment(self):
|
|
9
|
-
if self.
|
|
9
|
+
if self._key is None:
|
|
10
10
|
return "(<key>)"
|
|
11
|
-
elif isinstance(self.
|
|
12
|
-
return "({0})".format(self.
|
|
13
|
-
return "('{0}')".format(self.
|
|
11
|
+
elif isinstance(self._key, int):
|
|
12
|
+
return "({0})".format(self._key)
|
|
13
|
+
return "('{0}')".format(self._key)
|
|
14
14
|
|
|
15
15
|
@property
|
|
16
16
|
def delimiter(self):
|
|
File without changes
|
|
@@ -12,23 +12,25 @@ class EntityPath(ResourcePath):
|
|
|
12
12
|
|
|
13
13
|
@property
|
|
14
14
|
def collection(self):
|
|
15
|
+
from office365.onedrive.internal.paths.children import ChildrenPath
|
|
16
|
+
|
|
17
|
+
if self._collection is None:
|
|
18
|
+
if isinstance(self.parent, ChildrenPath):
|
|
19
|
+
self._collection = self.parent.collection
|
|
20
|
+
else:
|
|
21
|
+
self._collection = self.parent
|
|
15
22
|
return self._collection
|
|
16
23
|
|
|
17
24
|
@property
|
|
18
25
|
def segment(self):
|
|
19
|
-
return str(self.
|
|
26
|
+
return str(self._key or "<key>")
|
|
20
27
|
|
|
21
|
-
def patch(self, key
|
|
28
|
+
def patch(self, key):
|
|
22
29
|
"""
|
|
23
30
|
Patches path
|
|
24
|
-
|
|
25
31
|
:type key: str or None
|
|
26
|
-
:type inplace: bool
|
|
27
32
|
"""
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return self
|
|
33
|
-
else:
|
|
34
|
-
return ResourcePath(key, self.collection)
|
|
33
|
+
self._key = key
|
|
34
|
+
self._parent = self.collection
|
|
35
|
+
self.__class__ = EntityPath
|
|
36
|
+
return self
|
|
@@ -47,9 +47,7 @@ class EventHandler:
|
|
|
47
47
|
from office365.runtime.client_runtime_context import ClientRuntimeContext
|
|
48
48
|
|
|
49
49
|
if isinstance(listener, types.MethodType):
|
|
50
|
-
return isinstance(listener.__self__, ClientRequest)
|
|
51
|
-
listener.__self__, ClientRuntimeContext
|
|
52
|
-
)
|
|
50
|
+
return isinstance(listener.__self__, (ClientRequest, ClientRuntimeContext))
|
|
53
51
|
if isinstance(listener, types.FunctionType):
|
|
54
52
|
return listener.__module__ == ClientRuntimeContext.__module__
|
|
55
53
|
else:
|
office365/search/entity.py
CHANGED
|
@@ -31,28 +31,35 @@ class SearchEntity(Entity):
|
|
|
31
31
|
payload = {"requests": ClientValueCollection(SearchRequest, [search_request])}
|
|
32
32
|
return_type = ClientResult(self.context, ClientValueCollection(SearchResponse))
|
|
33
33
|
qry = ServiceOperationQuery(self, "query", None, payload, None, return_type)
|
|
34
|
-
|
|
34
|
+
|
|
35
|
+
def _patch_hit(search_hit):
|
|
36
|
+
pass
|
|
37
|
+
# resource = Entity(self.context)
|
|
38
|
+
# self.context.pending_request().map_json(search_hit.resource, resource)
|
|
39
|
+
# search_hit.set_property("resource", resource)
|
|
40
|
+
|
|
41
|
+
def _process_response():
|
|
42
|
+
for item in return_type.value:
|
|
43
|
+
for hcs in item.hitsContainers:
|
|
44
|
+
[_patch_hit(hit) for hit in hcs.hits]
|
|
45
|
+
|
|
46
|
+
self.context.add_query(qry).after_query_execute(_process_response)
|
|
35
47
|
return return_type
|
|
36
48
|
|
|
37
49
|
def query_messages(self, query_string):
|
|
38
|
-
"""Searches Outlook messages.
|
|
39
|
-
Alias to query method
|
|
40
|
-
|
|
50
|
+
"""Searches Outlook messages. Alias to query method
|
|
41
51
|
:param str query_string: Contains the query terms.
|
|
42
52
|
"""
|
|
43
53
|
return self.query(query_string, entity_types=[EntityType.message])
|
|
44
54
|
|
|
45
55
|
def query_events(self, query_string):
|
|
46
56
|
"""Searches Outlook calendar events. Alias to query method
|
|
47
|
-
|
|
48
57
|
:param str query_string: Contains the query terms.
|
|
49
58
|
"""
|
|
50
59
|
return self.query(query_string, entity_types=[EntityType.event])
|
|
51
60
|
|
|
52
61
|
def query_drive_items(self, query_string):
|
|
53
|
-
"""Searches OneDrive items.
|
|
54
|
-
Alias to query method
|
|
55
|
-
|
|
62
|
+
"""Searches OneDrive items. Alias to query method
|
|
56
63
|
:param str query_string: Contains the query terms.
|
|
57
64
|
"""
|
|
58
65
|
return self.query(query_string, entity_types=[EntityType.driveItem])
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
from typing import Optional
|
|
1
|
+
from typing import AnyStr, Optional
|
|
2
2
|
|
|
3
|
+
from office365.runtime.client_result import ClientResult
|
|
3
4
|
from office365.runtime.queries.service_operation import ServiceOperationQuery
|
|
4
5
|
from office365.sharepoint.entity import Entity
|
|
5
6
|
from office365.sharepoint.internal.queries.upload_file import create_upload_file_query
|
|
@@ -17,6 +18,7 @@ class Attachment(Entity):
|
|
|
17
18
|
"""
|
|
18
19
|
|
|
19
20
|
def _save_content(return_type):
|
|
21
|
+
# type: (ClientResult[AnyStr]) -> None
|
|
20
22
|
file_object.write(return_type.value)
|
|
21
23
|
|
|
22
24
|
def _download_file_by_path():
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import AnyStr
|
|
2
|
+
|
|
1
3
|
from office365.runtime.paths.service_operation import ServiceOperationPath
|
|
2
4
|
from office365.runtime.queries.service_operation import ServiceOperationQuery
|
|
3
5
|
from office365.sharepoint.attachments.attachment import Attachment
|
|
@@ -45,6 +47,7 @@ class AttachmentCollection(EntityCollection[Attachment]):
|
|
|
45
47
|
return return_type
|
|
46
48
|
|
|
47
49
|
def add_using_path(self, decoded_url, content_stream):
|
|
50
|
+
# type: (str, AnyStr) -> Attachment
|
|
48
51
|
"""
|
|
49
52
|
Adds the attachment represented by the file name and stream in the specified parameter to the list item.
|
|
50
53
|
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from office365.runtime.odata.type import ODataType
|
|
1
5
|
from office365.sharepoint.changes.token import ChangeToken
|
|
6
|
+
from office365.sharepoint.changes.type import ChangeType
|
|
2
7
|
from office365.sharepoint.entity import Entity
|
|
3
8
|
|
|
4
9
|
|
|
5
10
|
class Change(Entity):
|
|
6
11
|
"""Base class for a change. installation."""
|
|
7
12
|
|
|
13
|
+
@property
|
|
14
|
+
def change_type_name(self):
|
|
15
|
+
return ODataType.resolve_enum_key(ChangeType, self.change_type)
|
|
16
|
+
|
|
8
17
|
@property
|
|
9
18
|
def change_token(self):
|
|
10
19
|
"""
|
|
@@ -22,6 +31,7 @@ class Change(Entity):
|
|
|
22
31
|
|
|
23
32
|
@property
|
|
24
33
|
def site_id(self):
|
|
34
|
+
# type: () -> Optional[str]
|
|
25
35
|
"""
|
|
26
36
|
Returns the Id of the site of the changed item
|
|
27
37
|
"""
|
|
@@ -29,10 +39,11 @@ class Change(Entity):
|
|
|
29
39
|
|
|
30
40
|
@property
|
|
31
41
|
def time(self):
|
|
42
|
+
# type: () -> datetime.datetime
|
|
32
43
|
"""
|
|
33
44
|
Gets a value that specifies the time that the object was modified.
|
|
34
45
|
"""
|
|
35
|
-
return self.properties.get("Time",
|
|
46
|
+
return self.properties.get("Time", datetime.datetime.min)
|
|
36
47
|
|
|
37
48
|
def get_property(self, name, default_value=None):
|
|
38
49
|
if default_value is None:
|
|
@@ -2,7 +2,7 @@ from office365.sharepoint.changes.change import Change
|
|
|
2
2
|
from office365.sharepoint.entity_collection import EntityCollection
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class ChangeCollection(EntityCollection):
|
|
5
|
+
class ChangeCollection(EntityCollection[Change]):
|
|
6
6
|
"""Represents a collection of Change objects"""
|
|
7
7
|
|
|
8
8
|
def __init__(self, context, resource_path=None):
|
|
@@ -9,6 +9,9 @@ class ChangeList(Change):
|
|
|
9
9
|
The RelativeTime and RootFolderUrl properties are not included in the default scalar property set for this type.
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
+
def __repr__(self):
|
|
13
|
+
return "List: {0}".format(self.list_id)
|
|
14
|
+
|
|
12
15
|
@property
|
|
13
16
|
def base_template(self):
|
|
14
17
|
"""An SP.ListTemplateType object that returns the list template type of the list."""
|