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.
Files changed (271) hide show
  1. {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/METADATA +6 -6
  2. {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/RECORD +265 -259
  3. office365/base_item.py +12 -20
  4. office365/communications/onlinemeetings/collection.py +1 -1
  5. office365/communications/onlinemeetings/online_meeting.py +20 -35
  6. office365/communications/presences/presence.py +18 -7
  7. office365/delta_collection.py +10 -1
  8. office365/delta_path.py +1 -1
  9. office365/directory/administrative_unit.py +6 -7
  10. office365/directory/applications/application.py +24 -18
  11. office365/directory/applications/roles/assignment.py +13 -1
  12. office365/directory/applications/roles/collection.py +13 -0
  13. office365/directory/applications/roles/role.py +6 -1
  14. office365/directory/audit/directory.py +8 -7
  15. office365/directory/audit/log_root.py +3 -0
  16. office365/directory/audit/signins/signin.py +19 -29
  17. office365/directory/authentication/authentication.py +1 -0
  18. office365/directory/authentication/methods/details.py +8 -6
  19. office365/directory/authentication/methods/phone.py +3 -1
  20. office365/directory/extensions/extension_property.py +7 -9
  21. office365/directory/groups/collection.py +10 -3
  22. office365/directory/groups/group.py +19 -19
  23. office365/directory/groups/lifecycle_policy.py +8 -7
  24. office365/directory/identities/provider.py +5 -6
  25. office365/directory/insights/usage_details.py +8 -3
  26. office365/directory/internal/paths/me.py +1 -1
  27. office365/directory/invitations/collection.py +1 -1
  28. office365/directory/invitations/invitation.py +6 -6
  29. office365/directory/object_collection.py +2 -3
  30. office365/directory/permissions/email_identity.py +7 -0
  31. office365/directory/permissions/grants/resource_specific.py +10 -9
  32. office365/directory/permissions/identity.py +3 -0
  33. office365/directory/permissions/identity_set.py +3 -0
  34. office365/directory/policies/base.py +4 -4
  35. office365/directory/policies/root.py +6 -4
  36. office365/directory/protection/information.py +3 -3
  37. office365/directory/rolemanagement/application.py +2 -0
  38. office365/directory/rolemanagement/role.py +11 -10
  39. office365/directory/rolemanagement/template.py +9 -8
  40. office365/directory/rolemanagement/unified_role_assignment.py +5 -4
  41. office365/directory/rolemanagement/unified_role_definition.py +6 -4
  42. office365/directory/security/security.py +3 -0
  43. office365/directory/serviceprincipals/collection.py +20 -4
  44. office365/directory/serviceprincipals/service_principal.py +79 -12
  45. office365/directory/users/activities/activity.py +5 -4
  46. office365/directory/users/user.py +29 -34
  47. office365/entity.py +2 -2
  48. office365/entity_collection.py +12 -5
  49. office365/graph_client.py +90 -8
  50. office365/intune/audit/event.py +4 -3
  51. office365/intune/devices/enrollment/configuration.py +6 -4
  52. office365/intune/devices/managed.py +9 -12
  53. office365/onedrive/analytics/item_activity_stat.py +4 -3
  54. office365/onedrive/columns/column_link.py +4 -4
  55. office365/onedrive/columns/definition.py +29 -32
  56. office365/onedrive/columns/definition_collection.py +1 -1
  57. office365/onedrive/contenttypes/content_type.py +16 -18
  58. office365/onedrive/documentsets/version.py +7 -3
  59. office365/onedrive/driveitems/driveItem.py +48 -49
  60. office365/onedrive/drives/drive.py +7 -2
  61. office365/onedrive/internal/paths/children.py +2 -2
  62. office365/onedrive/internal/paths/root.py +1 -1
  63. office365/onedrive/internal/paths/shared.py +1 -1
  64. office365/onedrive/internal/paths/site.py +3 -3
  65. office365/onedrive/internal/paths/url.py +2 -2
  66. office365/onedrive/listitems/list_item.py +2 -0
  67. office365/onedrive/lists/list.py +7 -4
  68. office365/onedrive/permissions/collection.py +28 -7
  69. office365/onedrive/permissions/permission.py +5 -7
  70. office365/onedrive/permissions/sharing_link.py +1 -1
  71. office365/onedrive/sharepoint.py +1 -0
  72. office365/onedrive/shares/collection.py +2 -5
  73. office365/onedrive/shares/drive_item.py +4 -0
  74. office365/onedrive/sites/site.py +6 -0
  75. office365/onedrive/termstore/groups/collection.py +3 -8
  76. office365/onedrive/termstore/groups/group.py +8 -0
  77. office365/onedrive/termstore/sets/collection.py +2 -6
  78. office365/onedrive/termstore/sets/name.py +5 -0
  79. office365/onedrive/termstore/sets/set.py +7 -0
  80. office365/onedrive/termstore/store.py +10 -13
  81. office365/onedrive/versions/drive_item.py +3 -1
  82. office365/onedrive/workbooks/ranges/range.py +9 -13
  83. office365/onedrive/workbooks/ranges/view.py +1 -0
  84. office365/onedrive/workbooks/tables/rows/row.py +3 -0
  85. office365/onedrive/workbooks/tables/table.py +7 -4
  86. office365/onedrive/workbooks/worksheets/worksheet.py +12 -4
  87. office365/onenote/entity_hierarchy_model.py +4 -0
  88. office365/onenote/internal/multipart_page_query.py +4 -5
  89. office365/onenote/notebooks/notebook.py +4 -0
  90. office365/onenote/pages/collection.py +3 -2
  91. office365/onenote/resources/resource.py +5 -4
  92. office365/onenote/sectiongroups/section_group.py +10 -7
  93. office365/onenote/sections/section.py +1 -1
  94. office365/outlook/calendar/attendees/base.py +2 -1
  95. office365/outlook/calendar/calendar.py +18 -10
  96. office365/outlook/calendar/events/collection.py +0 -2
  97. office365/outlook/calendar/group.py +7 -8
  98. office365/outlook/calendar/meetingtimes/suggestion.py +8 -4
  99. office365/outlook/calendar/meetingtimes/time_slot.py +3 -0
  100. office365/outlook/calendar/permissions/collection.py +1 -1
  101. office365/outlook/calendar/rooms/__init__.py +0 -0
  102. office365/outlook/calendar/rooms/list.py +27 -0
  103. office365/outlook/calendar/rooms/room.py +8 -0
  104. office365/outlook/calendar/schedule/information.py +0 -1
  105. office365/outlook/contacts/collection.py +0 -8
  106. office365/outlook/contacts/contact.py +14 -14
  107. office365/outlook/contacts/folder.py +3 -0
  108. office365/outlook/mail/attachments/attachment.py +31 -31
  109. office365/outlook/mail/attachments/collection.py +34 -6
  110. office365/outlook/mail/conversation.py +6 -4
  111. office365/outlook/mail/folders/collection.py +0 -7
  112. office365/outlook/mail/folders/folder.py +50 -18
  113. office365/outlook/mail/messages/collection.py +0 -1
  114. office365/outlook/mail/messages/message.py +58 -68
  115. office365/outlook/mail/physical_address.py +11 -5
  116. office365/outlook/mail/recipient.py +3 -1
  117. office365/outlook/mail/recurrence_range.py +14 -6
  118. office365/outlook/user.py +1 -0
  119. office365/planner/planner.py +9 -12
  120. office365/planner/plans/collection.py +17 -18
  121. office365/planner/plans/container.py +11 -0
  122. office365/planner/plans/plan.py +21 -10
  123. office365/runtime/auth/authentication_context.py +3 -3
  124. office365/runtime/auth/providers/acs_token_provider.py +7 -9
  125. office365/runtime/auth/providers/saml_token_provider.py +5 -2
  126. office365/runtime/client_object.py +6 -15
  127. office365/runtime/client_object_collection.py +36 -35
  128. office365/runtime/client_result.py +6 -7
  129. office365/runtime/client_runtime_context.py +10 -16
  130. office365/runtime/client_value_collection.py +3 -10
  131. office365/runtime/compat.py +2 -0
  132. office365/runtime/odata/query_options.py +1 -3
  133. office365/runtime/odata/reader.py +1 -1
  134. office365/runtime/odata/request.py +2 -4
  135. office365/runtime/odata/type.py +17 -0
  136. office365/runtime/odata/v4/upload_session_request.py +27 -30
  137. office365/runtime/paths/appid.py +1 -1
  138. office365/runtime/{odata/url_builder.py → paths/builder.py} +24 -9
  139. office365/runtime/paths/item.py +3 -1
  140. office365/runtime/paths/resource_path.py +12 -16
  141. office365/runtime/paths/service_operation.py +8 -7
  142. office365/runtime/paths/v3/__init__.py +0 -0
  143. office365/runtime/paths/{key.py → v3/entity.py} +5 -5
  144. office365/runtime/paths/v4/__init__.py +0 -0
  145. office365/runtime/paths/{entity.py → v4/entity.py} +13 -11
  146. office365/runtime/queries/function.py +1 -1
  147. office365/runtime/types/event_handler.py +1 -3
  148. office365/search/entity.py +15 -8
  149. office365/search/external/external.py +1 -0
  150. office365/search/sort_property.py +3 -0
  151. office365/sharepoint/attachments/attachment.py +3 -1
  152. office365/sharepoint/attachments/collection.py +3 -0
  153. office365/sharepoint/changes/change.py +12 -1
  154. office365/sharepoint/changes/collection.py +1 -1
  155. office365/sharepoint/changes/list.py +3 -0
  156. office365/sharepoint/changes/token.py +4 -0
  157. office365/sharepoint/changes/type.py +23 -23
  158. office365/sharepoint/changes/web.py +7 -3
  159. office365/sharepoint/client_context.py +21 -18
  160. office365/sharepoint/clientsidecomponent/hostedapps/manager.py +3 -3
  161. office365/sharepoint/contenttypes/content_type.py +47 -56
  162. office365/sharepoint/contenttypes/content_type_id.py +1 -1
  163. office365/sharepoint/documentmanagement/document_id.py +2 -2
  164. office365/sharepoint/documentmanagement/document_set.py +6 -7
  165. office365/sharepoint/entity_collection.py +9 -0
  166. office365/sharepoint/features/feature.py +6 -8
  167. office365/sharepoint/fields/collection.py +6 -5
  168. office365/sharepoint/fields/field.py +28 -46
  169. office365/sharepoint/fields/related_field_collection.py +1 -1
  170. office365/sharepoint/fields/user_value.py +3 -3
  171. office365/sharepoint/files/checked_out_file.py +4 -2
  172. office365/sharepoint/files/checked_out_file_collection.py +1 -1
  173. office365/sharepoint/files/collection.py +84 -14
  174. office365/sharepoint/files/file.py +118 -110
  175. office365/sharepoint/files/versions/collection.py +5 -3
  176. office365/sharepoint/files/versions/event.py +6 -3
  177. office365/sharepoint/files/versions/version.py +31 -18
  178. office365/sharepoint/folders/collection.py +5 -10
  179. office365/sharepoint/folders/folder.py +41 -24
  180. office365/sharepoint/forms/collection.py +1 -1
  181. office365/sharepoint/forms/form.py +4 -4
  182. office365/sharepoint/internal/paths/static_operation.py +9 -0
  183. office365/sharepoint/internal/paths/web.py +20 -0
  184. office365/sharepoint/listitems/collection.py +4 -0
  185. office365/sharepoint/listitems/listitem.py +37 -38
  186. office365/sharepoint/listitems/versions/collection.py +1 -1
  187. office365/sharepoint/listitems/versions/version.py +18 -11
  188. office365/sharepoint/lists/collection.py +1 -2
  189. office365/sharepoint/lists/list.py +106 -153
  190. office365/sharepoint/marketplace/app_metadata_collection.py +3 -1
  191. office365/sharepoint/navigation/node.py +16 -15
  192. office365/sharepoint/navigation/node_collection.py +9 -3
  193. office365/sharepoint/permissions/base_permissions.py +11 -6
  194. office365/sharepoint/permissions/roles/assignments/collection.py +8 -12
  195. office365/sharepoint/permissions/roles/definitions/definition.py +3 -1
  196. office365/sharepoint/permissions/securable_object.py +38 -31
  197. office365/sharepoint/portal/groups/service.py +12 -16
  198. office365/sharepoint/portal/groups/site_manager.py +0 -1
  199. office365/sharepoint/principal/groups/group.py +24 -30
  200. office365/sharepoint/principal/principal.py +21 -19
  201. office365/sharepoint/principal/users/collection.py +5 -0
  202. office365/sharepoint/principal/users/user.py +20 -26
  203. office365/sharepoint/publishing/pages/collection.py +1 -4
  204. office365/sharepoint/publishing/pages/metadata.py +38 -51
  205. office365/sharepoint/publishing/pages/metadata_collection.py +5 -2
  206. office365/sharepoint/publishing/pages/page.py +12 -21
  207. office365/sharepoint/publishing/pages/reposts/repost.py +5 -9
  208. office365/sharepoint/publishing/pages/service.py +36 -49
  209. office365/sharepoint/pushnotifications/collection.py +3 -1
  210. office365/sharepoint/recyclebin/item.py +11 -9
  211. office365/sharepoint/recyclebin/item_collection.py +1 -1
  212. office365/sharepoint/search/service.py +8 -6
  213. office365/sharepoint/sharing/links/info.py +5 -2
  214. office365/sharepoint/sharing/links/share_response.py +3 -0
  215. office365/sharepoint/sharing/links/share_settings.py +3 -0
  216. office365/sharepoint/sharing/object_sharing_information.py +25 -19
  217. office365/sharepoint/sharing/object_sharing_information_user.py +10 -19
  218. office365/sharepoint/sharing/result.py +18 -41
  219. office365/sharepoint/sharing/role.py +20 -0
  220. office365/sharepoint/sharing/role_type.py +1 -0
  221. office365/sharepoint/sharing/user_sharing_result.py +12 -0
  222. office365/sharepoint/sites/language.py +6 -0
  223. office365/sharepoint/sites/language_collection.py +3 -0
  224. office365/sharepoint/sites/site.py +65 -86
  225. office365/sharepoint/storagemetrics/storage_metrics.py +5 -6
  226. office365/sharepoint/taxonomy/item.py +11 -10
  227. office365/sharepoint/taxonomy/stores/store.py +8 -8
  228. office365/sharepoint/taxonomy/terms/label.py +3 -0
  229. office365/sharepoint/taxonomy/terms/term.py +31 -0
  230. office365/sharepoint/tenant/administration/collaboration/insights_overview.py +10 -0
  231. office365/sharepoint/tenant/administration/hubsites/collection.py +1 -2
  232. office365/sharepoint/tenant/administration/hubsites/hub_site.py +20 -24
  233. office365/sharepoint/tenant/administration/internal/permission_grant.py +7 -0
  234. office365/sharepoint/tenant/administration/sites/properties.py +55 -44
  235. office365/sharepoint/tenant/administration/tenant.py +69 -69
  236. office365/sharepoint/types/resource_path.py +2 -2
  237. office365/sharepoint/ui/applicationpages/peoplepicker/query_parameters.py +1 -1
  238. office365/sharepoint/usercustomactions/collection.py +1 -2
  239. office365/sharepoint/userprofiles/my_site_links.py +4 -4
  240. office365/sharepoint/userprofiles/people_manager.py +1 -3
  241. office365/sharepoint/userprofiles/user_profile.py +9 -11
  242. office365/sharepoint/utilities/principal_info.py +12 -0
  243. office365/sharepoint/viva/employee_engagement.py +1 -1
  244. office365/sharepoint/webparts/definition_collection.py +1 -1
  245. office365/sharepoint/webs/collection.py +8 -0
  246. office365/sharepoint/webs/template_collection.py +3 -5
  247. office365/sharepoint/webs/web.py +75 -95
  248. office365/subscriptions/collection.py +1 -1
  249. office365/subscriptions/subscription.py +13 -11
  250. office365/teams/apps/app.py +1 -0
  251. office365/teams/channels/channel.py +1 -3
  252. office365/teams/collection.py +12 -16
  253. office365/teams/info.py +7 -4
  254. office365/teams/members/conversation_collection.py +1 -3
  255. office365/teams/operations/async_operation.py +3 -5
  256. office365/teams/schedule/groups/group.py +3 -0
  257. office365/teams/team.py +18 -20
  258. office365/todo/attachments/base.py +7 -9
  259. office365/todo/linked_resource.py +6 -6
  260. office365/todo/tasks/list.py +1 -0
  261. office365/todo/tasks/task.py +3 -0
  262. office365/onedrive/internal/queries/resumable_file_upload.py +0 -36
  263. office365/outlook/internal/queries/attachment_upload.py +0 -53
  264. office365/runtime/odata/path_builder.py +0 -23
  265. office365/sharepoint/internal/key_value.py +0 -28
  266. office365/sharepoint/internal/queries/create_file.py +0 -20
  267. office365/sharepoint/internal/queries/upload_session.py +0 -103
  268. {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/LICENSE +0 -0
  269. {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/WHEEL +0 -0
  270. {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/top_level.txt +0 -0
  271. /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) or isinstance(
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) or isinstance(payload, ClientValue):
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 {
@@ -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._range_start = 0
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(range_data)))
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._range_start, self._range_end - 1, self.file_size
31
+ self.range_start, self.range_end - 1, self.file_size
34
32
  ),
35
33
  )
36
34
  request.set_header("Accept", "*/*")
37
- request.data = range_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 _read_next(self):
52
- self._range_start = self._file_object.tell()
53
- content = self._file_object.read(self._chunk_size)
54
- self._range_end = self._file_object.tell()
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
- @property
58
- def has_pending_read(self):
59
- return self._range_end < self.file_size
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
- return self._range_start
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._range_end
68
+ return self._file_object.tell()
@@ -7,7 +7,7 @@ class AppIdPath(ResourcePath):
7
7
 
8
8
  @property
9
9
  def segment(self):
10
- return "(appId='{0}')".format(self.key)
10
+ return "(appId='{0}')".format(self._key)
11
11
 
12
12
  @property
13
13
  def delimiter(self):
@@ -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
- class ODataUrlBuilder(object):
12
+
13
+ class ODataPathBuilder(object):
8
14
  @staticmethod
9
- def build_segment(path):
10
- """
11
- Constructs url for path segment
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
- :type path: office365.runtime.paths.service_operation.ServiceOperationPath
14
- """
15
- url = path.key or ""
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, ODataUrlBuilder._encode_method_value(value))
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" % (ODataUrlBuilder._encode_method_value(value))
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
  ]
@@ -1,6 +1,8 @@
1
- from office365.runtime.paths.entity import EntityPath
1
+ from office365.runtime.paths.v4.entity import EntityPath
2
2
 
3
3
 
4
4
  class ItemPath(EntityPath):
5
+ """ """
6
+
5
7
  def __init__(self, parent=None):
6
8
  super(ItemPath, self).__init__(None, parent, parent)
@@ -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, inplace=False):
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.key)
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.odata.url_builder import ODataUrlBuilder
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 ODataUrlBuilder.build_segment(self)
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 KeyPath(ResourcePath):
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.key is None:
9
+ if self._key is None:
10
10
  return "(<key>)"
11
- elif isinstance(self.key, int):
12
- return "({0})".format(self.key)
13
- return "('{0}')".format(self.key)
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.key or "<key>")
26
+ return str(self._key or "<key>")
20
27
 
21
- def patch(self, key, inplace=False):
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
- if inplace:
29
- self._key = key
30
- self._parent = self.collection
31
- self.__class__ = ResourcePath
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
@@ -3,7 +3,7 @@ from office365.runtime.queries.client_query import ClientQuery
3
3
 
4
4
 
5
5
  class FunctionQuery(ClientQuery):
6
- """ "Service operation query"""
6
+ """Function query"""
7
7
 
8
8
  def __init__(
9
9
  self, binding_type, method_name=None, method_params=None, return_type=None
@@ -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) or isinstance(
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:
@@ -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
- self.context.add_query(qry)
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])
@@ -9,6 +9,7 @@ class External(Entity):
9
9
 
10
10
  @property
11
11
  def connections(self):
12
+ # type: () -> EntityCollection[ExternalConnection]
12
13
  """Get a list of the externalConnection objects and their properties."""
13
14
  return self.properties.get(
14
15
  "connections",
@@ -12,3 +12,6 @@ class SortProperty(ClientValue):
12
12
  """
13
13
  self.isDescending = is_descending
14
14
  self.name = name
15
+
16
+ def __repr__(self):
17
+ return "{0} {1}".format(self.name, "DESC" if self.isDescending else "ASC")
@@ -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", None)
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."""
@@ -23,3 +23,7 @@ class ChangeToken(ClientValue):
23
23
 
24
24
  def __repr__(self):
25
25
  return self.StringValue or ""
26
+
27
+ @property
28
+ def entity_type_name(self):
29
+ return "SP.ChangeToken"