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
@@ -1,7 +1,10 @@
1
+ from typing import IO, AnyStr, Optional
2
+
3
+ from typing_extensions import Self
4
+
1
5
  from office365.runtime.client_result import ClientResult
2
- from office365.runtime.paths.key import KeyPath
3
6
  from office365.runtime.paths.resource_path import ResourcePath
4
- from office365.runtime.paths.service_operation import ServiceOperationPath
7
+ from office365.runtime.paths.v3.entity import EntityPath
5
8
  from office365.runtime.queries.service_operation import ServiceOperationQuery
6
9
  from office365.sharepoint.entity import Entity
7
10
 
@@ -9,25 +12,30 @@ from office365.sharepoint.entity import Entity
9
12
  class FileVersion(Entity):
10
13
  """Represents a version of a File object."""
11
14
 
15
+ def __str__(self):
16
+ return self.version_label
17
+
18
+ def __repr__(self):
19
+ return "Is Current: {0}, {1}".format(
20
+ self.is_current_version, self.version_label
21
+ )
22
+
12
23
  def download(self, file_object):
13
- """Downloads the file version as a stream and save into a file.
24
+ # type: (IO) -> Self
25
+ """Downloads the file version as a stream and save into a file."""
14
26
 
15
- :type file_object: typing.IO
16
- """
27
+ def _save_file(return_type):
28
+ # type: (ClientResult[AnyStr]) -> None
29
+ file_object.write(return_type.value)
17
30
 
18
31
  def _file_version_loaded():
19
- def _save_file(return_type):
20
- """
21
- :type return_type:ClientResult
22
- """
23
- file_object.write(return_type.value)
24
-
25
32
  self.open_binary_stream().after_execute(_save_file)
26
33
 
27
34
  self.ensure_property("ID", _file_version_loaded)
28
35
  return self
29
36
 
30
37
  def open_binary_stream(self):
38
+ # type: () -> ClientResult[AnyStr]
31
39
  """Opens the file as a stream."""
32
40
  return_type = ClientResult(self.context)
33
41
  qry = ServiceOperationQuery(
@@ -37,6 +45,7 @@ class FileVersion(Entity):
37
45
  return return_type
38
46
 
39
47
  def open_binary_stream_with_options(self, open_options):
48
+ # type: (int) -> ClientResult[AnyStr]
40
49
  """Opens the file as a stream."""
41
50
  return_type = ClientResult(self.context)
42
51
  qry = ServiceOperationQuery(
@@ -57,30 +66,32 @@ class FileVersion(Entity):
57
66
 
58
67
  @property
59
68
  def id(self):
69
+ # type: () -> Optional[int]
60
70
  """Gets a file version identifier"""
61
71
  return int(self.properties.get("ID", -1))
62
72
 
63
73
  @property
64
74
  def url(self):
75
+ # type: () -> Optional[str]
65
76
  """Gets a value that specifies the relative URL of the file version based on the URL for the site or subsite."""
66
77
  return self.properties.get("Url", None)
67
78
 
68
79
  @property
69
80
  def version_label(self):
81
+ # type: () -> Optional[str]
70
82
  """Gets a value that specifies the implementation specific identifier of the file."""
71
83
  return self.properties.get("VersionLabel", None)
72
84
 
73
85
  @property
74
86
  def is_current_version(self):
87
+ # type: () -> Optional[bool]
75
88
  """Gets a value that specifies whether the file version is the current version."""
76
89
  return self.properties.get("IsCurrentVersion", None)
77
90
 
78
91
  @property
79
92
  def checkin_comment(self):
80
- """Gets a value that specifies the check-in comment.
81
-
82
- :rtype: str or None
83
- """
93
+ # type: () -> Optional[str]
94
+ """Gets a value that specifies the check-in comment."""
84
95
  return self.properties.get("CheckInComment", None)
85
96
 
86
97
  def get_property(self, name, default_value=None):
@@ -93,9 +104,11 @@ class FileVersion(Entity):
93
104
 
94
105
  def set_property(self, key, value, persist_changes=True):
95
106
  super(FileVersion, self).set_property(key, value, persist_changes)
96
- if self._resource_path is None:
97
- if key == "ID":
98
- self._resource_path = KeyPath(
107
+ if key.lower() == self.property_ref_name.lower():
108
+ if self._resource_path is None:
109
+ self._resource_path = EntityPath(
99
110
  value, self.parent_collection.resource_path
100
111
  )
112
+ else:
113
+ self._resource_path.patch(value)
101
114
  return self
@@ -1,5 +1,5 @@
1
- from office365.runtime.paths.key import KeyPath
2
1
  from office365.runtime.paths.service_operation import ServiceOperationPath
2
+ from office365.runtime.paths.v3.entity import EntityPath
3
3
  from office365.runtime.queries.service_operation import ServiceOperationQuery
4
4
  from office365.sharepoint.entity_collection import EntityCollection
5
5
  from office365.sharepoint.folders.folder import Folder
@@ -15,22 +15,20 @@ class FolderCollection(EntityCollection[Folder]):
15
15
  def add_using_path(self, decoded_url, overwrite):
16
16
  """
17
17
  Adds the folder located at the specified path to the collection.
18
-
19
18
  :param str decoded_url: Specifies the path for the folder.
20
19
  :param bool overwrite: bool
21
20
  """
22
21
  parameters = {"DecodedUrl": decoded_url, "Overwrite": overwrite}
23
- target_folder = Folder(self.context)
22
+ return_type = Folder(self.context)
24
23
  qry = ServiceOperationQuery(
25
- self, "AddUsingPath", parameters, None, None, target_folder
24
+ self, "AddUsingPath", parameters, None, None, return_type
26
25
  )
27
26
  self.context.add_query(qry)
28
- return target_folder
27
+ return return_type
29
28
 
30
29
  def ensure_path(self, path):
31
30
  """
32
31
  Ensures a folder exist
33
-
34
32
  :param str path: server or site relative url to a folder
35
33
  """
36
34
  path = path.replace(self.context.site_path, "")
@@ -46,10 +44,9 @@ class FolderCollection(EntityCollection[Folder]):
46
44
 
47
45
  def add(self, name):
48
46
  """Adds the folder that is located at the specified URL to the collection.
49
-
50
47
  :param str name: Specifies the Name of the folder.
51
48
  """
52
- return_type = Folder(self.context, KeyPath(name, self.resource_path))
49
+ return_type = Folder(self.context, EntityPath(name, self.resource_path))
53
50
  self.add_child(return_type)
54
51
  qry = ServiceOperationQuery(self, "Add", [name], None, None, return_type)
55
52
  self.context.add_query(qry)
@@ -57,7 +54,6 @@ class FolderCollection(EntityCollection[Folder]):
57
54
 
58
55
  def get_by_url(self, url):
59
56
  """Retrieve Folder resource by url
60
-
61
57
  :param str url: Specifies the URL of the list folder. The URL MUST be an absolute URL, a server-relative URL,
62
58
  a site-relative URL relative to the site (2) containing the collection of list folders, or relative to the
63
59
  list folder that directly contains this collection of list folders.
@@ -69,7 +65,6 @@ class FolderCollection(EntityCollection[Folder]):
69
65
  def get_by_path(self, decoded_url):
70
66
  """
71
67
  Get folder at the specified path.
72
-
73
68
  :param str decoded_url: Specifies the path for the folder.
74
69
  """
75
70
  return Folder(
@@ -14,6 +14,7 @@ from office365.sharepoint.contenttypes.content_type_id import ContentTypeId
14
14
  from office365.sharepoint.entity import Entity
15
15
  from office365.sharepoint.listitems.listitem import ListItem
16
16
  from office365.sharepoint.sharing.document_manager import DocumentSharingManager
17
+ from office365.sharepoint.sharing.links.share_response import ShareLinkResponse
17
18
  from office365.sharepoint.sharing.user_sharing_result import UserSharingResult
18
19
  from office365.sharepoint.storagemetrics.storage_metrics import StorageMetrics
19
20
  from office365.sharepoint.types.resource_path import ResourcePath as SPResPath
@@ -28,11 +29,16 @@ if TYPE_CHECKING:
28
29
  class Folder(Entity):
29
30
  """Represents a folder in a SharePoint Web site."""
30
31
 
32
+ def __str__(self):
33
+ return self.name
34
+
35
+ def __repr__(self):
36
+ return self.serverRelativeUrl or self.unique_id or self.entity_type_name
37
+
31
38
  @staticmethod
32
39
  def from_url(abs_url):
33
40
  """
34
41
  Addresses a Folder by absolute url
35
-
36
42
  :type abs_url: str
37
43
  """
38
44
  from office365.sharepoint.client_context import ClientContext
@@ -54,12 +60,31 @@ class Folder(Entity):
54
60
  self, download_file, after_file_downloaded, recursive
55
61
  )
56
62
 
63
+ def get_folders(self, recursive=False):
64
+ """
65
+ Retrieves folders
66
+ :param bool recursive: Determines whether to enumerate folders recursively
67
+ """
68
+ from office365.sharepoint.folders.collection import FolderCollection # noqa
69
+
70
+ return_type = FolderCollection(self.context, self.folders.resource_path, self)
71
+
72
+ def _loaded(parent):
73
+ # type: ("Folder") -> None
74
+ [return_type.add_child(f) for f in parent.folders]
75
+ if recursive:
76
+ for folder in parent.folders:
77
+ folder.ensure_properties(["Folders"], _loaded, parent=folder)
78
+
79
+ self.ensure_properties(["Folders"], _loaded, parent=self)
80
+ return return_type
81
+
57
82
  def get_files(self, recursive=False):
58
83
  """
59
84
  Retrieves files
60
85
  :param bool recursive: Determines whether to enumerate folders recursively
61
86
  """
62
- from office365.sharepoint.files.collection import FileCollection
87
+ from office365.sharepoint.files.collection import FileCollection # noqa
63
88
 
64
89
  return_type = FileCollection(self.context, self.files.resource_path, self)
65
90
 
@@ -125,9 +150,7 @@ class Folder(Entity):
125
150
  self.set_property("ServerRelativePath", url)
126
151
 
127
152
  def _move_to_using_path(destination_folder):
128
- """
129
- :type destination_folder: Folder
130
- """
153
+ # type: ("Folder") -> None
131
154
  destination_url = "/".join(
132
155
  [str(destination_folder.server_relative_path), self.name]
133
156
  )
@@ -177,18 +200,19 @@ class Folder(Entity):
177
200
  return return_type
178
201
 
179
202
  def share_link(self, link_kind, expiration=None, role=None, password=None):
203
+ # type: (int, Optional[datetime], Optional[int], Optional[str]) -> ClientResult[ShareLinkResponse]
180
204
  """Creates a tokenized sharing link for a folder based on the specified parameters and optionally
181
205
  sends an email to the people that are listed in the specified parameters.
182
206
 
183
- :param int link_kind: The kind of the tokenized sharing link to be created/updated or retrieved.
184
- :param datetime.datetime or None expiration: A date/time string for which the format conforms to the ISO 8601:2004(E)
207
+ :param link_kind: The kind of the tokenized sharing link to be created/updated or retrieved.
208
+ :param expiration: A date/time string for which the format conforms to the ISO 8601:2004(E)
185
209
  complete representation for calendar date and time of day and which represents the time and date of expiry
186
210
  for the tokenized sharing link. Both the minutes and hour value MUST be specified for the difference
187
211
  between the local and UTC time. Midnight is represented as 00:00:00. A null value indicates no expiry.
188
212
  This value is only applicable to tokenized sharing links that are anonymous access links.
189
- :param int role: The role to be used for the tokenized sharing link. This is required for Flexible links
213
+ :param role: The role to be used for the tokenized sharing link. This is required for Flexible links
190
214
  and ignored for all other kinds.
191
- :param str password: Optional password value to apply to the tokenized sharing link,
215
+ :param password: Optional password value to apply to the tokenized sharing link,
192
216
  if it can support password protection.
193
217
  """
194
218
  return self.list_item_all_fields.share_link(
@@ -264,10 +288,8 @@ class Folder(Entity):
264
288
  return self.folders.add(name)
265
289
 
266
290
  def rename(self, name):
267
- """Rename a Folder resource
268
-
269
- :type name: str
270
- """
291
+ # type: (str) -> Self
292
+ """Rename a Folder resource"""
271
293
  item = self.list_item_all_fields
272
294
  item.set_property("Title", name)
273
295
  item.set_property("FileLeafRef", name)
@@ -428,6 +450,7 @@ class Folder(Entity):
428
450
 
429
451
  @property
430
452
  def storage_metrics(self):
453
+ # type: () -> StorageMetrics
431
454
  """Specifies the storage-related metrics for list folders in the site"""
432
455
  return self.properties.get(
433
456
  "StorageMetrics",
@@ -451,7 +474,7 @@ class Folder(Entity):
451
474
  def files(self):
452
475
  # type: () -> FileCollection
453
476
  """Specifies the collection of files contained in the list folder."""
454
- from office365.sharepoint.files.collection import FileCollection
477
+ from office365.sharepoint.files.collection import FileCollection # noqa
455
478
 
456
479
  return self.properties.get(
457
480
  "Files",
@@ -464,7 +487,7 @@ class Folder(Entity):
464
487
  def folders(self):
465
488
  # type: () -> FolderCollection
466
489
  """Specifies the collection of list folders contained within the list folder."""
467
- from office365.sharepoint.folders.collection import FolderCollection
490
+ from office365.sharepoint.folders.collection import FolderCollection # noqa
468
491
 
469
492
  return self.properties.get(
470
493
  "Folders",
@@ -489,9 +512,7 @@ class Folder(Entity):
489
512
  @property
490
513
  def is_wopi_enabled(self):
491
514
  # type: () -> Optional[bool]
492
- """
493
- Indicates whether the folder is enabled for WOPI default action.
494
- """
515
+ """Indicates whether the folder is enabled for WOPI default action."""
495
516
  return self.properties.get("IsWOPIEnabled", None)
496
517
 
497
518
  @property
@@ -545,17 +566,13 @@ class Folder(Entity):
545
566
  @property
546
567
  def serverRelativeUrl(self):
547
568
  # type: () -> Optional[str]
548
- """
549
- Gets the server-relative URL of the list folder.
550
- """
569
+ """Gets the server-relative URL of the list folder."""
551
570
  return self.properties.get("ServerRelativeUrl", None)
552
571
 
553
572
  @property
554
573
  def server_relative_path(self):
555
574
  # type: () -> Optional[SPResPath]
556
- """
557
- Gets the server-relative Path of the list folder.
558
- """
575
+ """Gets the server-relative Path of the list folder."""
559
576
  return self.properties.get("ServerRelativePath", SPResPath())
560
577
 
561
578
  @property
@@ -3,7 +3,7 @@ from office365.sharepoint.entity_collection import EntityCollection
3
3
  from office365.sharepoint.forms.form import Form
4
4
 
5
5
 
6
- class FormCollection(EntityCollection):
6
+ class FormCollection(EntityCollection[Form]):
7
7
  def __init__(self, context, resource_path=None):
8
8
  """Specifies a collection of list forms for a list."""
9
9
  super(FormCollection, self).__init__(context, Form, resource_path)
@@ -1,3 +1,5 @@
1
+ from typing import Optional
2
+
1
3
  from office365.sharepoint.entity import Entity
2
4
  from office365.sharepoint.types.resource_path import ResourcePath as SPResPath
3
5
 
@@ -7,19 +9,17 @@ class Form(Entity):
7
9
 
8
10
  @property
9
11
  def form_type(self):
12
+ # type: () -> Optional[str]
10
13
  """
11
14
  Gets the type of the form.
12
-
13
- :rtype: str or None
14
15
  """
15
16
  return self.properties.get("FormType", None)
16
17
 
17
18
  @property
18
19
  def server_relative_url(self):
20
+ # type: () -> Optional[str]
19
21
  """
20
22
  Gets the server-relative URL of the form.
21
-
22
- :rtype: str or None
23
23
  """
24
24
  return self.properties.get("ServerRelativeUrl", None)
25
25
 
@@ -0,0 +1,9 @@
1
+ from typing import Dict, Optional
2
+
3
+ from office365.runtime.paths.service_operation import ServiceOperationPath
4
+
5
+
6
+ class StaticOperationPath(ServiceOperationPath):
7
+ def __init__(self, static_name, parameters=None):
8
+ # type: (str, Optional[Dict]) -> None
9
+ super(StaticOperationPath, self).__init__(static_name, parameters)
@@ -0,0 +1,20 @@
1
+ from office365.runtime.compat import is_absolute_url, urlparse
2
+ from office365.runtime.paths.resource_path import ResourcePath
3
+
4
+
5
+ class WebPath(ResourcePath):
6
+ @property
7
+ def segment(self):
8
+ return "Web"
9
+
10
+ @property
11
+ def web_path(self):
12
+ if is_absolute_url(self._key):
13
+ url_parts = urlparse(self._key)
14
+ return url_parts.path
15
+ else:
16
+ return self._key
17
+
18
+ @property
19
+ def parent(self):
20
+ return None
@@ -31,3 +31,7 @@ class ListItemCollection(EntityCollection[ListItem]):
31
31
  self.context,
32
32
  ServiceOperationPath("GetByStringId", {"sId": s_id}, self.resource_path),
33
33
  )
34
+
35
+ def get_by_url(self, url):
36
+ """Returns the list item with the specified site or server relative url."""
37
+ return self.single("FileRef eq '{0}'".format(url))
@@ -1,9 +1,10 @@
1
1
  import json
2
+ from typing import TYPE_CHECKING
2
3
 
3
4
  from office365.runtime.client_result import ClientResult
4
5
  from office365.runtime.client_value_collection import ClientValueCollection
5
- from office365.runtime.paths.key import KeyPath
6
6
  from office365.runtime.paths.resource_path import ResourcePath
7
+ from office365.runtime.paths.v3.entity import EntityPath
7
8
  from office365.runtime.queries.service_operation import ServiceOperationQuery
8
9
  from office365.sharepoint.attachments.collection import AttachmentCollection
9
10
  from office365.sharepoint.changes.collection import ChangeCollection
@@ -33,6 +34,10 @@ from office365.sharepoint.ui.applicationpages.peoplepicker.web_service_interface
33
34
  ClientPeoplePickerWebServiceInterface,
34
35
  )
35
36
 
37
+ if TYPE_CHECKING:
38
+ import datetime
39
+ from typing import Optional
40
+
36
41
 
37
42
  class ListItem(SecurableObject):
38
43
  """An individual entry within a SharePoint list. Each list item has a schema that maps to fields in the list
@@ -50,28 +55,31 @@ class ListItem(SecurableObject):
50
55
  self.set_property("ParentList", parent_list, False)
51
56
 
52
57
  def share_link(self, link_kind, expiration=None, role=None, password=None):
58
+ # type: (int, Optional[datetime.datetime], Optional[int], Optional[str]) -> ClientResult[ShareLinkResponse]
53
59
  """Creates a tokenized sharing link for a list item based on the specified parameters and optionally
54
60
  sends an email to the people that are listed in the specified parameters.
55
61
 
56
- :param int link_kind: The kind of the tokenized sharing link to be created/updated or retrieved.
57
- :param datetime.datetime or None expiration: A date/time string for which the format conforms to the ISO 8601:2004(E)
62
+ :param link_kind: The kind of the tokenized sharing link to be created/updated or retrieved.
63
+ :param expiration: A date/time string for which the format conforms to the ISO 8601:2004(E)
58
64
  complete representation for calendar date and time of day and which represents the time and date of expiry
59
65
  for the tokenized sharing link. Both the minutes and hour value MUST be specified for the difference
60
66
  between the local and UTC time. Midnight is represented as 00:00:00. A null value indicates no expiry.
61
67
  This value is only applicable to tokenized sharing links that are anonymous access links.
62
- :param int role: The role to be used for the tokenized sharing link. This is required for Flexible links
68
+ :param role: The role to be used for the tokenized sharing link. This is required for Flexible links
63
69
  and ignored for all other kinds.
64
- :param str password: Optional password value to apply to the tokenized sharing link,
70
+ :param password: Optional password value to apply to the tokenized sharing link,
65
71
  if it can support password protection.
66
72
  """
67
- return_type = ClientResult(
68
- self.context, ShareLinkResponse()
69
- ) # type: ClientResult[ShareLinkResponse]
73
+ return_type = ClientResult(self.context, ShareLinkResponse())
70
74
  request = ShareLinkRequest(
71
75
  settings=ShareLinkSettings(
72
76
  link_kind=link_kind, expiration=expiration, role=role, password=password
73
77
  )
74
78
  )
79
+ if password:
80
+ request.settings.allowAnonymousAccess = True
81
+ request.settings.updatePassword = True
82
+
75
83
  payload = {"request": request}
76
84
  qry = ServiceOperationQuery(self, "ShareLink", None, payload, None, return_type)
77
85
  self.context.add_query(qry)
@@ -233,9 +241,7 @@ class ListItem(SecurableObject):
233
241
  return return_type
234
242
 
235
243
  def unshare(self):
236
- """
237
- Unshare a ListItem (file or folder facet)
238
- """
244
+ """Unshare a ListItem (file or folder facet)"""
239
245
  return_type = SharingResult(self.context)
240
246
 
241
247
  def _property_resolved():
@@ -364,10 +370,8 @@ class ListItem(SecurableObject):
364
370
 
365
371
  @property
366
372
  def display_name(self):
367
- """Specifies the display name of the list item.
368
-
369
- :rtype: str or None
370
- """
373
+ # type: () -> Optional[str]
374
+ """Specifies the display name of the list item."""
371
375
  return self.properties.get("DisplayName", None)
372
376
 
373
377
  @property
@@ -402,7 +406,9 @@ class ListItem(SecurableObject):
402
406
  def attachment_files(self):
403
407
  # type: () -> AttachmentCollection
404
408
  """Specifies the collection of attachments that are associated with the list item.<62>"""
405
- from office365.sharepoint.attachments.collection import AttachmentCollection
409
+ from office365.sharepoint.attachments.collection import (
410
+ AttachmentCollection, # noqa
411
+ )
406
412
 
407
413
  return self.properties.get(
408
414
  "AttachmentFiles",
@@ -431,34 +437,26 @@ class ListItem(SecurableObject):
431
437
 
432
438
  @property
433
439
  def field_values(self):
440
+ # type: () -> Optional[dict]
434
441
  """Gets a collection of key/value pairs containing the names and values for the fields of the list item."""
435
442
  return self.properties.get("FieldValues", None)
436
443
 
437
444
  @property
438
445
  def comments_disabled(self):
439
- """
440
- Indicates whether comments for this item are disabled or not.
441
-
442
- :rtype: bool or None
443
- """
446
+ # type: () -> Optional[bool]
447
+ """Indicates whether comments for this item are disabled or not."""
444
448
  return self.properties.get("CommentsDisabled", None)
445
449
 
446
450
  @property
447
451
  def file_system_object_type(self):
448
- """
449
- Gets a value that specifies whether the list item is a file or a list folder.
450
-
451
- :rtype: str or None
452
- """
452
+ # type: () -> Optional[str]
453
+ """Gets a value that specifies whether the list item is a file or a list folder"""
453
454
  return self.properties.get("FileSystemObjectType", None)
454
455
 
455
456
  @property
456
457
  def id(self):
457
- """
458
- Gets a value that specifies the list item identifier.
459
-
460
- :rtype: int
461
- """
458
+ # type: () -> Optional[int]
459
+ """Gets a value that specifies the list item identifier."""
462
460
  return self.properties.get("Id", None)
463
461
 
464
462
  @property
@@ -467,6 +465,7 @@ class ListItem(SecurableObject):
467
465
 
468
466
  @property
469
467
  def comments_disabled_scope(self):
468
+ # type: () -> Optional[str]
470
469
  """Indicates at what scope comments are disabled."""
471
470
  return self.properties.get("CommentsDisabledScope", None)
472
471
 
@@ -492,9 +491,7 @@ class ListItem(SecurableObject):
492
491
 
493
492
  @property
494
493
  def liked_by_information(self):
495
- """
496
- Gets a value that specifies the list item identifier.
497
- """
494
+ """Gets a value that specifies the list item identifier."""
498
495
  return self.properties.get(
499
496
  "LikedByInformation",
500
497
  LikedByInformation(
@@ -560,17 +557,19 @@ class ListItem(SecurableObject):
560
557
  super(ListItem, self).set_property(name, value, persist_changes)
561
558
 
562
559
  # fallback: create a new resource path
563
- if self._resource_path is None and self.parent_collection is not None:
564
- if name == "Id":
565
- self._resource_path = KeyPath(
560
+ if name == "Id":
561
+ if self._resource_path is None and self.parent_collection is not None:
562
+ self._resource_path = EntityPath(
566
563
  value, self.parent_collection.resource_path
567
564
  )
565
+ else:
566
+ self._resource_path.patch(value)
568
567
  return self
569
568
 
570
569
  def _set_taxonomy_field_value(self, name, value):
570
+ # type: (str, TaxonomyFieldValueCollection) -> None
571
571
  """
572
572
  Sets taxonomy field value
573
-
574
573
  :param str name: Taxonomy field name
575
574
  :param TaxonomyFieldValueCollection value: Taxonomy field value
576
575
  """
@@ -7,7 +7,7 @@ from office365.sharepoint.listitems.versions.get_parameters import (
7
7
  from office365.sharepoint.listitems.versions.version import ListItemVersion
8
8
 
9
9
 
10
- class ListItemVersionCollection(EntityCollection):
10
+ class ListItemVersionCollection(EntityCollection[ListItemVersion]):
11
11
  """Specifies a collection of versions of a list item."""
12
12
 
13
13
  def __init__(self, context, resource_path=None):
@@ -1,30 +1,39 @@
1
1
  import datetime
2
+ from typing import TYPE_CHECKING, Optional
2
3
 
3
4
  from office365.runtime.paths.resource_path import ResourcePath
4
- from office365.runtime.paths.service_operation import ServiceOperationPath
5
5
  from office365.sharepoint.entity import Entity
6
6
 
7
+ if TYPE_CHECKING:
8
+ from office365.sharepoint.listitems.versions.collection import (
9
+ ListItemVersionCollection,
10
+ )
11
+
7
12
 
8
13
  class ListItemVersion(Entity):
9
14
  """Represents a version of a list item."""
10
15
 
16
+ def __repr__(self):
17
+ return "Label: {0}, Url: {1}".format(
18
+ self.version_label, self.properties.get("FileRef", None)
19
+ )
20
+
11
21
  @property
12
22
  def version_id(self):
23
+ # type: () -> Optional[int]
13
24
  """Gets the ID of the version."""
14
- return int(self.properties.get("VersionId", -1))
25
+ return int(self.properties.get("VersionId", None))
15
26
 
16
27
  @property
17
28
  def version_label(self):
18
- """Gets the version number of the item version.
19
- :rtype: str or None
20
- """
29
+ # type: () -> Optional[str]
30
+ """Gets the version number of the item version."""
21
31
  return self.properties.get("VersionLabel", None)
22
32
 
23
33
  @property
24
34
  def is_current_version(self):
25
- """Gets a value that specifies whether the file version is the current version.
26
- :rtype: bool
27
- """
35
+ # type: () -> Optional[bool]
36
+ """Gets a value that specifies whether the file version is the current version."""
28
37
  return self.properties.get("IsCurrentVersion", None)
29
38
 
30
39
  @property
@@ -68,9 +77,7 @@ class ListItemVersion(Entity):
68
77
 
69
78
  @property
70
79
  def parent_collection(self):
71
- """
72
- :rtype: office365.sharepoint.listitems.versions.collection.ListItemVersionCollection
73
- """
80
+ # type: () -> ListItemVersionCollection
74
81
  return self._parent_collection
75
82
 
76
83
  def get_property(self, name, default_value=None):