Office365-REST-Python-Client 2.5.2__py3-none-any.whl → 2.5.4__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 (138) hide show
  1. {Office365_REST_Python_Client-2.5.2.dist-info → Office365_REST_Python_Client-2.5.4.dist-info}/METADATA +18 -5
  2. {Office365_REST_Python_Client-2.5.2.dist-info → Office365_REST_Python_Client-2.5.4.dist-info}/RECORD +135 -131
  3. office365/base_item.py +12 -20
  4. office365/communications/presences/presence.py +18 -7
  5. office365/delta_path.py +1 -1
  6. office365/directory/administrative_unit.py +6 -7
  7. office365/directory/applications/application.py +15 -13
  8. office365/directory/applications/template.py +5 -8
  9. office365/directory/audit/signins/signin.py +8 -12
  10. office365/directory/authentication/methods/details.py +8 -6
  11. office365/directory/authentication/methods/email.py +4 -4
  12. office365/directory/groups/lifecycle_policy.py +8 -7
  13. office365/directory/identities/provider.py +5 -6
  14. office365/directory/internal/paths/me.py +1 -1
  15. office365/directory/permissions/email_identity.py +7 -0
  16. office365/directory/protection/riskyusers/history_item.py +4 -3
  17. office365/directory/rolemanagement/role.py +5 -4
  18. office365/directory/rolemanagement/template.py +2 -6
  19. office365/directory/rolemanagement/unified_role_assignment.py +5 -4
  20. office365/directory/rolemanagement/unified_role_definition.py +6 -4
  21. office365/directory/serviceprincipals/service_principal.py +11 -6
  22. office365/directory/users/user.py +8 -11
  23. office365/entity.py +2 -2
  24. office365/entity_collection.py +11 -4
  25. office365/intune/devices/enrollment/configuration.py +6 -4
  26. office365/intune/devices/managed.py +9 -12
  27. office365/onedrive/analytics/item_activity_stat.py +4 -3
  28. office365/onedrive/columns/definition.py +9 -9
  29. office365/onedrive/documentsets/version.py +1 -3
  30. office365/onedrive/driveitems/driveItem.py +36 -29
  31. office365/onedrive/internal/paths/children.py +2 -2
  32. office365/onedrive/internal/paths/root.py +1 -1
  33. office365/onedrive/internal/paths/shared.py +11 -6
  34. office365/onedrive/internal/paths/site.py +3 -3
  35. office365/onedrive/internal/paths/url.py +2 -2
  36. office365/onedrive/listitems/list_item.py +2 -0
  37. office365/onedrive/lists/list.py +7 -4
  38. office365/onedrive/permissions/collection.py +26 -6
  39. office365/onedrive/sharepoint.py +1 -0
  40. office365/onedrive/shares/collection.py +2 -5
  41. office365/onedrive/shares/drive_item.py +5 -1
  42. office365/onedrive/termstore/groups/collection.py +3 -8
  43. office365/onedrive/termstore/groups/group.py +8 -0
  44. office365/onedrive/termstore/sets/collection.py +2 -6
  45. office365/onedrive/termstore/sets/name.py +5 -0
  46. office365/onedrive/termstore/sets/set.py +7 -0
  47. office365/onedrive/termstore/store.py +10 -13
  48. office365/onedrive/versions/drive_item.py +6 -8
  49. office365/onedrive/workbooks/functions/result.py +1 -1
  50. office365/onedrive/workbooks/names/collection.py +26 -0
  51. office365/onedrive/workbooks/names/named_item.py +23 -6
  52. office365/onedrive/workbooks/ranges/range.py +61 -14
  53. office365/onedrive/workbooks/ranges/view.py +1 -0
  54. office365/onedrive/workbooks/tables/table.py +11 -8
  55. office365/onedrive/workbooks/workbook.py +7 -11
  56. office365/onedrive/workbooks/worksheets/worksheet.py +5 -3
  57. office365/onenote/pages/collection.py +3 -2
  58. office365/onenote/resources/resource.py +5 -4
  59. office365/onenote/sectiongroups/section_group.py +10 -7
  60. office365/outlook/calendar/calendar.py +1 -1
  61. office365/outlook/calendar/schedule/information.py +0 -1
  62. office365/outlook/contacts/contact.py +3 -9
  63. office365/outlook/contacts/folder.py +3 -0
  64. office365/outlook/item.py +3 -4
  65. office365/outlook/mail/messages/message.py +25 -18
  66. office365/outlook/mail/recipient.py +3 -1
  67. office365/runtime/auth/authentication_context.py +6 -4
  68. office365/runtime/auth/providers/acs_token_provider.py +21 -15
  69. office365/runtime/auth/providers/saml_token_provider.py +5 -2
  70. office365/runtime/auth/sts_profile.py +5 -2
  71. office365/runtime/client_object.py +3 -11
  72. office365/runtime/client_object_collection.py +22 -20
  73. office365/runtime/client_result.py +1 -3
  74. office365/runtime/client_value_collection.py +2 -6
  75. office365/runtime/odata/json_format.py +1 -5
  76. office365/runtime/odata/query_options.py +1 -3
  77. office365/runtime/odata/request.py +8 -13
  78. office365/runtime/odata/type.py +2 -0
  79. office365/runtime/paths/appid.py +1 -1
  80. office365/runtime/{odata/url_builder.py → paths/builder.py} +24 -9
  81. office365/runtime/paths/item.py +1 -1
  82. office365/runtime/paths/resource_path.py +12 -16
  83. office365/runtime/paths/service_operation.py +8 -7
  84. office365/runtime/paths/v3/__init__.py +0 -0
  85. office365/runtime/paths/{key.py → v3/entity.py} +5 -5
  86. office365/runtime/paths/v4/__init__.py +0 -0
  87. office365/runtime/paths/v4/entity.py +35 -0
  88. office365/sharepoint/client_context.py +17 -10
  89. office365/sharepoint/contenttypes/content_type.py +6 -0
  90. office365/sharepoint/documentmanagement/document_set.py +4 -6
  91. office365/sharepoint/entity_collection.py +9 -0
  92. office365/sharepoint/features/feature.py +6 -8
  93. office365/sharepoint/files/checked_out_file.py +4 -2
  94. office365/sharepoint/files/checked_out_file_collection.py +1 -1
  95. office365/sharepoint/files/collection.py +35 -3
  96. office365/sharepoint/files/file.py +35 -11
  97. office365/sharepoint/files/versions/collection.py +4 -0
  98. office365/sharepoint/files/versions/event.py +6 -3
  99. office365/sharepoint/files/versions/version.py +6 -4
  100. office365/sharepoint/folders/collection.py +2 -2
  101. office365/sharepoint/folders/folder.py +5 -11
  102. office365/sharepoint/internal/paths/static_operation.py +9 -0
  103. office365/sharepoint/internal/paths/web.py +20 -0
  104. office365/sharepoint/listitems/collection.py +4 -0
  105. office365/sharepoint/listitems/listitem.py +19 -30
  106. office365/sharepoint/lists/list.py +44 -60
  107. office365/sharepoint/portal/groups/service.py +12 -16
  108. office365/sharepoint/portal/groups/site_manager.py +0 -1
  109. office365/sharepoint/publishing/pages/metadata.py +7 -2
  110. office365/sharepoint/publishing/pages/metadata_collection.py +0 -1
  111. office365/sharepoint/publishing/pages/page.py +3 -6
  112. office365/sharepoint/publishing/pages/reposts/repost.py +5 -9
  113. office365/sharepoint/recyclebin/item.py +11 -9
  114. office365/sharepoint/sharing/links/share_response.py +3 -0
  115. office365/sharepoint/sharing/result.py +18 -41
  116. office365/sharepoint/sites/site.py +46 -68
  117. office365/sharepoint/taxonomy/item.py +4 -2
  118. office365/sharepoint/taxonomy/stores/store.py +2 -6
  119. office365/sharepoint/tenant/administration/internal/permission_grant.py +7 -0
  120. office365/sharepoint/tenant/administration/sites/properties.py +55 -44
  121. office365/sharepoint/tenant/administration/tenant.py +25 -40
  122. office365/sharepoint/usercustomactions/collection.py +0 -1
  123. office365/sharepoint/webs/collection.py +8 -0
  124. office365/sharepoint/webs/template_collection.py +2 -4
  125. office365/sharepoint/webs/web.py +27 -24
  126. office365/teams/apps/app.py +1 -0
  127. office365/teams/collection.py +12 -16
  128. office365/teams/members/conversation_collection.py +1 -3
  129. office365/teams/operations/async_operation.py +3 -5
  130. office365/teams/schedule/groups/group.py +3 -0
  131. office365/teams/team.py +1 -1
  132. office365/todo/attachments/base.py +7 -9
  133. office365/runtime/odata/path_builder.py +0 -23
  134. office365/runtime/paths/entity.py +0 -34
  135. office365/sharepoint/internal/key_value.py +0 -28
  136. {Office365_REST_Python_Client-2.5.2.dist-info → Office365_REST_Python_Client-2.5.4.dist-info}/LICENSE +0 -0
  137. {Office365_REST_Python_Client-2.5.2.dist-info → Office365_REST_Python_Client-2.5.4.dist-info}/WHEEL +0 -0
  138. {Office365_REST_Python_Client-2.5.2.dist-info → Office365_REST_Python_Client-2.5.4.dist-info}/top_level.txt +0 -0
@@ -3,7 +3,7 @@ from office365.sharepoint.entity_collection import EntityCollection
3
3
  from office365.sharepoint.files.checked_out_file import CheckedOutFile
4
4
 
5
5
 
6
- class CheckedOutFileCollection(EntityCollection):
6
+ class CheckedOutFileCollection(EntityCollection[CheckedOutFile]):
7
7
  def __init__(self, context, resource_path=None):
8
8
  super(CheckedOutFileCollection, self).__init__(
9
9
  context, CheckedOutFile, resource_path
@@ -1,23 +1,31 @@
1
+ import hashlib
1
2
  import os
2
3
  import uuid
3
- from typing import IO, Callable
4
+ from typing import IO, TYPE_CHECKING, Callable
4
5
 
5
6
  from office365.runtime.client_result import ClientResult
7
+ from office365.runtime.paths.resource_path import ResourcePath
6
8
  from office365.runtime.paths.service_operation import ServiceOperationPath
7
9
  from office365.runtime.queries.service_operation import ServiceOperationQuery
10
+ from office365.sharepoint.client_context import ClientContext
8
11
  from office365.sharepoint.entity_collection import EntityCollection
9
12
  from office365.sharepoint.files.creation_information import FileCreationInformation
10
13
  from office365.sharepoint.files.file import File
11
14
  from office365.sharepoint.types.resource_path import ResourcePath as SPResPath
12
15
 
16
+ if TYPE_CHECKING:
17
+ from office365.sharepoint.folders.folder import Folder
18
+
13
19
 
14
20
  class FileCollection(EntityCollection[File]):
15
21
  """Represents a collection of File resources."""
16
22
 
17
23
  def __init__(self, context, resource_path=None, parent=None):
24
+ # type: (ClientContext, ResourcePath, Folder) -> None
18
25
  super(FileCollection, self).__init__(context, File, resource_path, parent)
19
26
 
20
27
  def upload(self, path_or_file):
28
+ # type: (str|IO) -> File
21
29
  """Uploads a file into folder.
22
30
 
23
31
  Note: This method only supports files up to 4MB in size!
@@ -34,6 +42,23 @@ class FileCollection(EntityCollection[File]):
34
42
  name = os.path.basename(path_or_file)
35
43
  return self.add(name, content, True)
36
44
 
45
+ def upload_with_checksum(self, file_object, chunk_size=1024):
46
+ # type: (IO, int) -> File
47
+ """ """
48
+ h = hashlib.sha1() # hashlib.md5()
49
+ file_name = os.path.basename(file_object.name)
50
+ upload_id = str(uuid.uuid4())
51
+
52
+ def _upload_session(return_type):
53
+ # type: (File) -> None
54
+ content = file_object.read(chunk_size)
55
+ h.update(content)
56
+ return_type.upload_with_checksum(
57
+ upload_id, h.hexdigest(), content
58
+ ).after_execute(_upload_session)
59
+
60
+ return self.add(file_name, None, True).after_execute(_upload_session)
61
+
37
62
  def create_upload_session(
38
63
  self, file, chunk_size, chunk_uploaded=None, file_name=None, **kwargs
39
64
  ):
@@ -118,7 +143,7 @@ class FileCollection(EntityCollection[File]):
118
143
  return_type = File(self.context)
119
144
  self.add_child(return_type)
120
145
 
121
- def _parent_folder_loaded():
146
+ def _add_template_file():
122
147
  params = {
123
148
  "urlOfFile": str(
124
149
  SPResPath.create_relative(
@@ -132,17 +157,24 @@ class FileCollection(EntityCollection[File]):
132
157
  )
133
158
  self.context.add_query(qry)
134
159
 
135
- self.parent.ensure_property("ServerRelativeUrl", _parent_folder_loaded)
160
+ self.parent.ensure_property("ServerRelativeUrl", _add_template_file)
136
161
  return return_type
137
162
 
138
163
  def get_by_url(self, url):
164
+ # type: (str) -> File
139
165
  """Retrieve File object by url"""
140
166
  return File(
141
167
  self.context, ServiceOperationPath("GetByUrl", [url], self.resource_path)
142
168
  )
143
169
 
144
170
  def get_by_id(self, _id):
171
+ # type: (int) -> File
145
172
  """Gets the File with the specified ID."""
146
173
  return File(
147
174
  self.context, ServiceOperationPath("getById", [_id], self.resource_path)
148
175
  )
176
+
177
+ @property
178
+ def parent(self):
179
+ # type: () -> Folder
180
+ return self._parent
@@ -64,6 +64,9 @@ class File(AbstractFile):
64
64
  else:
65
65
  return self.serverRelativeUrl or self.unique_id or self.entity_type_name
66
66
 
67
+ def __str__(self):
68
+ return self.name or self.entity_type_name
69
+
67
70
  @staticmethod
68
71
  def from_url(abs_url):
69
72
  """
@@ -251,20 +254,23 @@ class File(AbstractFile):
251
254
  self.context.add_query(qry)
252
255
  return self
253
256
 
254
- def copyto(self, destination, overwrite=False):
255
- # type: (Folder|str, bool) -> File
257
+ def copyto(self, destination, overwrite=False, file_name=None):
258
+ # type: (Folder|str, bool, str) -> "File"
256
259
  """Copies the file to the destination URL.
257
260
 
258
261
  :param office365.sharepoint.folders.folder.Folder or str destination: Specifies the destination folder or
259
262
  folder server relative url where to copy a file.
260
263
  :param bool overwrite: Specifies whether a file with the same name is overwritten.
264
+ :param str file_name: A new file name
261
265
  """
262
266
  return_type = File(self.context)
263
267
  self.parent_collection.add_child(return_type)
264
268
 
265
269
  def _copyto(destination_folder):
266
270
  # type: (Folder) -> None
267
- file_path = "/".join([str(destination_folder.serverRelativeUrl), self.name])
271
+ file_path = "/".join(
272
+ [str(destination_folder.serverRelativeUrl), file_name or self.name]
273
+ )
268
274
  return_type.set_property("ServerRelativeUrl", file_path)
269
275
 
270
276
  params = {"strNewUrl": file_path, "boverwrite": overwrite}
@@ -280,7 +286,7 @@ class File(AbstractFile):
280
286
  self.ensure_properties(["ServerRelativeUrl", "Name"], _source_file_resolved)
281
287
  return return_type
282
288
 
283
- def copyto_using_path(self, destination, overwrite=False):
289
+ def copyto_using_path(self, destination, overwrite=False, file_name=None):
284
290
  """
285
291
  Copies the file to the destination path. Server MUST overwrite an existing file of the same name
286
292
  if overwrite is true.
@@ -288,6 +294,7 @@ class File(AbstractFile):
288
294
  :param bool overwrite: Specifies whether a file with the same name is overwritten.
289
295
  :param office365.sharepoint.folders.folder.Folder or str destination: Specifies the destination folder or
290
296
  folder server relative url where to copy a file.
297
+ :param str file_name: New file name
291
298
  """
292
299
 
293
300
  return_type = File(self.context)
@@ -296,7 +303,7 @@ class File(AbstractFile):
296
303
  def _copyto_using_path(destination_folder):
297
304
  # type: (Folder) -> None
298
305
  file_path = "/".join(
299
- [str(destination_folder.server_relative_path), self.name]
306
+ [str(destination_folder.server_relative_path), file_name or self.name]
300
307
  )
301
308
  return_type.set_property("ServerRelativePath", file_path)
302
309
 
@@ -473,7 +480,6 @@ class File(AbstractFile):
473
480
 
474
481
  def get_upload_status(self, upload_id):
475
482
  """Gets the status of a chunk upload session.
476
-
477
483
  :param str upload_id: The upload session ID.
478
484
  """
479
485
  payload = {
@@ -493,9 +499,9 @@ class File(AbstractFile):
493
499
  :param bytes stream:
494
500
  """
495
501
  return_type = File(self.context)
496
- payload = {"uploadId": upload_id, "checksum": checksum, "stream": stream}
502
+ params = {"uploadId": upload_id, "checksum": checksum}
497
503
  qry = ServiceOperationQuery(
498
- self, "UploadWithChecksum", None, payload, None, return_type
504
+ self, "UploadWithChecksum", params, stream, None, return_type
499
505
  )
500
506
  self.context.add_query(qry)
501
507
  return return_type
@@ -564,6 +570,26 @@ class File(AbstractFile):
564
570
  self.context.add_query(qry)
565
571
  return self
566
572
 
573
+ def finish_upload_with_checksum(self, upload_id, file_offset, checksum, stream):
574
+ """Uploads the last file fragment and commits the file. The current file content is changed when this method
575
+ completes.
576
+
577
+ :param str upload_id: Upload session id
578
+ :param int file_offset: File offset
579
+ :param str checksum: File checksum
580
+ :param bytes stream: File content
581
+ """
582
+ payload = {
583
+ "uploadID": upload_id,
584
+ "fileOffset": file_offset,
585
+ "checksum": checksum,
586
+ }
587
+ qry = ServiceOperationQuery(
588
+ self, "FinishUploadWithChecksum", payload, stream, None, self
589
+ )
590
+ self.context.add_query(qry)
591
+ return self
592
+
567
593
  @staticmethod
568
594
  def save_binary(context, server_relative_url, content):
569
595
  """Uploads a file
@@ -734,9 +760,7 @@ class File(AbstractFile):
734
760
 
735
761
  @property
736
762
  def information_rights_management_settings(self):
737
- """
738
- Returns the Information Rights Management (IRM) settings for the file.
739
- """
763
+ """Returns the Information Rights Management (IRM) settings for the file."""
740
764
  return self.properties.get(
741
765
  "InformationRightsManagementSettings",
742
766
  InformationRightsManagementFileSettings(
@@ -17,6 +17,10 @@ class FileVersionCollection(EntityCollection[FileVersion]):
17
17
  ServiceOperationPath("getById", [version_id], self.resource_path),
18
18
  )
19
19
 
20
+ def get_by_label(self, label):
21
+ """Gets the file version with the specified Label."""
22
+ return self.single("VersionLabel eq '{0}'".format(label))
23
+
20
24
  def delete_all(self):
21
25
  """Deletes all the file version objects in the collection."""
22
26
  qry = ServiceOperationQuery(self, "DeleteAll")
@@ -1,3 +1,5 @@
1
+ from typing import Optional
2
+
1
3
  from office365.runtime.client_value_collection import ClientValueCollection
2
4
  from office365.sharepoint.entity import Entity
3
5
  from office365.sharepoint.sharing.shared_with_user import SharedWithUser
@@ -8,14 +10,14 @@ class FileVersionEvent(Entity):
8
10
 
9
11
  @property
10
12
  def event_type(self):
13
+ # type: () -> Optional[str]
11
14
  """Returns the type of the event."""
12
15
  return self.properties.get("EventType", None)
13
16
 
14
17
  @property
15
18
  def editor(self):
16
- """Returns the name of the user who initiated the event.
17
- :rtype: str or None
18
- """
19
+ # type: () -> Optional[str]
20
+ """Returns the name of the user who initiated the event."""
19
21
  return self.properties.get("Editor", None)
20
22
 
21
23
  @property
@@ -25,6 +27,7 @@ class FileVersionEvent(Entity):
25
27
 
26
28
  @property
27
29
  def shared_with_users(self):
30
+ # type: () -> ClientValueCollection[SharedWithUser]
28
31
  """Returns the array of users that have been shared in sharing action for the change log."""
29
32
  return self.properties.get(
30
33
  "SharedWithUsers", ClientValueCollection(SharedWithUser)
@@ -3,8 +3,8 @@ from typing import IO, AnyStr, Optional
3
3
  from typing_extensions import Self
4
4
 
5
5
  from office365.runtime.client_result import ClientResult
6
- from office365.runtime.paths.key import KeyPath
7
6
  from office365.runtime.paths.resource_path import ResourcePath
7
+ from office365.runtime.paths.v3.entity import EntityPath
8
8
  from office365.runtime.queries.service_operation import ServiceOperationQuery
9
9
  from office365.sharepoint.entity import Entity
10
10
 
@@ -104,9 +104,11 @@ class FileVersion(Entity):
104
104
 
105
105
  def set_property(self, key, value, persist_changes=True):
106
106
  super(FileVersion, self).set_property(key, value, persist_changes)
107
- if self._resource_path is None:
108
- if key == "ID":
109
- 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(
110
110
  value, self.parent_collection.resource_path
111
111
  )
112
+ else:
113
+ self._resource_path.patch(value)
112
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
@@ -46,7 +46,7 @@ class FolderCollection(EntityCollection[Folder]):
46
46
  """Adds the folder that is located at the specified URL to the collection.
47
47
  :param str name: Specifies the Name of the folder.
48
48
  """
49
- return_type = Folder(self.context, KeyPath(name, self.resource_path))
49
+ return_type = Folder(self.context, EntityPath(name, self.resource_path))
50
50
  self.add_child(return_type)
51
51
  qry = ServiceOperationQuery(self, "Add", [name], None, None, return_type)
52
52
  self.context.add_query(qry)
@@ -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
@@ -38,7 +39,6 @@ class Folder(Entity):
38
39
  def from_url(abs_url):
39
40
  """
40
41
  Addresses a Folder by absolute url
41
-
42
42
  :type abs_url: str
43
43
  """
44
44
  from office365.sharepoint.client_context import ClientContext
@@ -150,9 +150,7 @@ class Folder(Entity):
150
150
  self.set_property("ServerRelativePath", url)
151
151
 
152
152
  def _move_to_using_path(destination_folder):
153
- """
154
- :type destination_folder: Folder
155
- """
153
+ # type: ("Folder") -> None
156
154
  destination_url = "/".join(
157
155
  [str(destination_folder.server_relative_path), self.name]
158
156
  )
@@ -202,7 +200,7 @@ class Folder(Entity):
202
200
  return return_type
203
201
 
204
202
  def share_link(self, link_kind, expiration=None, role=None, password=None):
205
- # type: (int, Optional[datetime], Optional[int], Optional[str]) -> str
203
+ # type: (int, Optional[datetime], Optional[int], Optional[str]) -> ClientResult[ShareLinkResponse]
206
204
  """Creates a tokenized sharing link for a folder based on the specified parameters and optionally
207
205
  sends an email to the people that are listed in the specified parameters.
208
206
 
@@ -514,9 +512,7 @@ class Folder(Entity):
514
512
  @property
515
513
  def is_wopi_enabled(self):
516
514
  # type: () -> Optional[bool]
517
- """
518
- Indicates whether the folder is enabled for WOPI default action.
519
- """
515
+ """Indicates whether the folder is enabled for WOPI default action."""
520
516
  return self.properties.get("IsWOPIEnabled", None)
521
517
 
522
518
  @property
@@ -570,9 +566,7 @@ class Folder(Entity):
570
566
  @property
571
567
  def serverRelativeUrl(self):
572
568
  # type: () -> Optional[str]
573
- """
574
- Gets the server-relative URL of the list folder.
575
- """
569
+ """Gets the server-relative URL of the list folder."""
576
570
  return self.properties.get("ServerRelativeUrl", None)
577
571
 
578
572
  @property
@@ -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))
@@ -3,8 +3,8 @@ from typing import TYPE_CHECKING
3
3
 
4
4
  from office365.runtime.client_result import ClientResult
5
5
  from office365.runtime.client_value_collection import ClientValueCollection
6
- from office365.runtime.paths.key import KeyPath
7
6
  from office365.runtime.paths.resource_path import ResourcePath
7
+ from office365.runtime.paths.v3.entity import EntityPath
8
8
  from office365.runtime.queries.service_operation import ServiceOperationQuery
9
9
  from office365.sharepoint.attachments.collection import AttachmentCollection
10
10
  from office365.sharepoint.changes.collection import ChangeCollection
@@ -241,9 +241,7 @@ class ListItem(SecurableObject):
241
241
  return return_type
242
242
 
243
243
  def unshare(self):
244
- """
245
- Unshare a ListItem (file or folder facet)
246
- """
244
+ """Unshare a ListItem (file or folder facet)"""
247
245
  return_type = SharingResult(self.context)
248
246
 
249
247
  def _property_resolved():
@@ -372,10 +370,8 @@ class ListItem(SecurableObject):
372
370
 
373
371
  @property
374
372
  def display_name(self):
375
- """Specifies the display name of the list item.
376
-
377
- :rtype: str or None
378
- """
373
+ # type: () -> Optional[str]
374
+ """Specifies the display name of the list item."""
379
375
  return self.properties.get("DisplayName", None)
380
376
 
381
377
  @property
@@ -441,34 +437,26 @@ class ListItem(SecurableObject):
441
437
 
442
438
  @property
443
439
  def field_values(self):
440
+ # type: () -> Optional[dict]
444
441
  """Gets a collection of key/value pairs containing the names and values for the fields of the list item."""
445
442
  return self.properties.get("FieldValues", None)
446
443
 
447
444
  @property
448
445
  def comments_disabled(self):
449
- """
450
- Indicates whether comments for this item are disabled or not.
451
-
452
- :rtype: bool or None
453
- """
446
+ # type: () -> Optional[bool]
447
+ """Indicates whether comments for this item are disabled or not."""
454
448
  return self.properties.get("CommentsDisabled", None)
455
449
 
456
450
  @property
457
451
  def file_system_object_type(self):
458
- """
459
- Gets a value that specifies whether the list item is a file or a list folder.
460
-
461
- :rtype: str or None
462
- """
452
+ # type: () -> Optional[str]
453
+ """Gets a value that specifies whether the list item is a file or a list folder"""
463
454
  return self.properties.get("FileSystemObjectType", None)
464
455
 
465
456
  @property
466
457
  def id(self):
467
- """
468
- Gets a value that specifies the list item identifier.
469
-
470
- :rtype: int
471
- """
458
+ # type: () -> Optional[int]
459
+ """Gets a value that specifies the list item identifier."""
472
460
  return self.properties.get("Id", None)
473
461
 
474
462
  @property
@@ -477,6 +465,7 @@ class ListItem(SecurableObject):
477
465
 
478
466
  @property
479
467
  def comments_disabled_scope(self):
468
+ # type: () -> Optional[str]
480
469
  """Indicates at what scope comments are disabled."""
481
470
  return self.properties.get("CommentsDisabledScope", None)
482
471
 
@@ -502,9 +491,7 @@ class ListItem(SecurableObject):
502
491
 
503
492
  @property
504
493
  def liked_by_information(self):
505
- """
506
- Gets a value that specifies the list item identifier.
507
- """
494
+ """Gets a value that specifies the list item identifier."""
508
495
  return self.properties.get(
509
496
  "LikedByInformation",
510
497
  LikedByInformation(
@@ -570,17 +557,19 @@ class ListItem(SecurableObject):
570
557
  super(ListItem, self).set_property(name, value, persist_changes)
571
558
 
572
559
  # fallback: create a new resource path
573
- if self._resource_path is None and self.parent_collection is not None:
574
- if name == "Id":
575
- 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(
576
563
  value, self.parent_collection.resource_path
577
564
  )
565
+ else:
566
+ self._resource_path.patch(value)
578
567
  return self
579
568
 
580
569
  def _set_taxonomy_field_value(self, name, value):
570
+ # type: (str, TaxonomyFieldValueCollection) -> None
581
571
  """
582
572
  Sets taxonomy field value
583
-
584
573
  :param str name: Taxonomy field name
585
574
  :param TaxonomyFieldValueCollection value: Taxonomy field value
586
575
  """