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
@@ -28,6 +28,9 @@ from office365.runtime.types.collections import StringCollection
28
28
  class ServicePrincipal(DirectoryObject):
29
29
  """Represents an instance of an application in a directory."""
30
30
 
31
+ def __str__(self):
32
+ return self.display_name
33
+
31
34
  def add_key(self, key_credential, password_credential, proof):
32
35
  """
33
36
  Adds a key credential to a servicePrincipal. This method along with removeKey can be used by a servicePrincipal
@@ -185,9 +188,7 @@ class ServicePrincipal(DirectoryObject):
185
188
  @property
186
189
  def app_display_name(self):
187
190
  # type: () -> Optional[str]
188
- """
189
- The display name exposed by the associated application.
190
- """
191
+ """The display name exposed by the associated application."""
191
192
  return self.properties.get("appDisplayName", None)
192
193
 
193
194
  @property
@@ -209,12 +210,16 @@ class ServicePrincipal(DirectoryObject):
209
210
  """
210
211
  return self.properties.get("appRoles", AppRoleCollection())
211
212
 
213
+ @property
214
+ def display_name(self):
215
+ # type: () -> Optional[str]
216
+ """The display name."""
217
+ return self.properties.get("displayName", None)
218
+
212
219
  @property
213
220
  def homepage(self):
214
221
  # type: () -> Optional[str]
215
- """
216
- Home page or landing page of the application.
217
- """
222
+ """Home page or landing page of the application"""
218
223
  return self.properties.get("homepage", None)
219
224
 
220
225
  @property
@@ -55,8 +55,8 @@ from office365.runtime.client_result import ClientResult
55
55
  from office365.runtime.client_value_collection import ClientValueCollection
56
56
  from office365.runtime.http.http_method import HttpMethod
57
57
  from office365.runtime.http.request_options import RequestOptions
58
- from office365.runtime.paths.entity import EntityPath
59
58
  from office365.runtime.paths.resource_path import ResourcePath
59
+ from office365.runtime.paths.v4.entity import EntityPath
60
60
  from office365.runtime.queries.create_entity import CreateEntityQuery
61
61
  from office365.runtime.queries.function import FunctionQuery
62
62
  from office365.runtime.queries.service_operation import ServiceOperationQuery
@@ -71,6 +71,9 @@ from office365.todo.todo import Todo
71
71
  class User(DirectoryObject):
72
72
  """Represents an Azure AD user account. Inherits from directoryObject."""
73
73
 
74
+ def __repr__(self):
75
+ return self.user_principal_name or self.id or self.entity_type_name
76
+
74
77
  def add_extension(self, name):
75
78
  """
76
79
  Creates an open extension (openTypeExtension object) and add custom properties in a new or existing instance
@@ -621,9 +624,7 @@ class User(DirectoryObject):
621
624
 
622
625
  @property
623
626
  def photo(self):
624
- """
625
- The user's profile photo. Read-only.
626
- """
627
+ """The user's profile photo. Read-only."""
627
628
  return self.properties.get(
628
629
  "photo",
629
630
  ProfilePhoto(self.context, ResourcePath("photo", self.resource_path)),
@@ -631,9 +632,7 @@ class User(DirectoryObject):
631
632
 
632
633
  @property
633
634
  def manager(self):
634
- """
635
- The user or contact that is this user's manager
636
- """
635
+ """The user or contact that is this user's manager"""
637
636
  return self.properties.get(
638
637
  "manager",
639
638
  DirectoryObject(self.context, ResourcePath("manager", self.resource_path)),
@@ -641,17 +640,15 @@ class User(DirectoryObject):
641
640
 
642
641
  @property
643
642
  def preferred_language(self):
643
+ # type: () -> Optional[str]
644
644
  """
645
645
  The preferred language for the user. Should follow ISO 639-1 Code; for example en-US.
646
- :rtype: str or None
647
646
  """
648
647
  return self.properties.get("preferredLanguage", None)
649
648
 
650
649
  @property
651
650
  def mailbox_settings(self):
652
- """
653
- Get the user's mailboxSettings.
654
- """
651
+ """Get the user's mailboxSettings."""
655
652
  return self.properties.get("mailboxSettings", MailboxSettings())
656
653
 
657
654
  @property
office365/entity.py CHANGED
@@ -3,8 +3,8 @@ from typing import TYPE_CHECKING, Optional, TypeVar
3
3
  from typing_extensions import Self
4
4
 
5
5
  from office365.runtime.client_object import ClientObject
6
- from office365.runtime.paths.entity import EntityPath
7
6
  from office365.runtime.paths.resource_path import ResourcePath
7
+ from office365.runtime.paths.v4.entity import EntityPath
8
8
  from office365.runtime.queries.delete_entity import DeleteEntityQuery
9
9
  from office365.runtime.queries.update_entity import UpdateEntityQuery
10
10
 
@@ -72,5 +72,5 @@ class Entity(ClientObject[T]):
72
72
  value, self.parent_collection.resource_path
73
73
  )
74
74
  else:
75
- self._resource_path.patch(value, inplace=True)
75
+ self._resource_path.patch(value)
76
76
  return self
@@ -5,6 +5,7 @@ from office365.runtime.client_object_collection import ClientObjectCollection
5
5
  from office365.runtime.compat import is_string_type
6
6
  from office365.runtime.paths.item import ItemPath
7
7
  from office365.runtime.paths.resource_path import ResourcePath
8
+ from office365.runtime.paths.v4.entity import EntityPath
8
9
  from office365.runtime.queries.create_entity import CreateEntityQuery
9
10
 
10
11
  if TYPE_CHECKING:
@@ -32,7 +33,7 @@ class EntityCollection(ClientObjectCollection[T]):
32
33
  return super(EntityCollection, self).__getitem__(key)
33
34
  elif is_string_type(key):
34
35
  return self.create_typed_object(
35
- resource_path=ResourcePath(key, self.resource_path)
36
+ resource_path=EntityPath(key, self.resource_path)
36
37
  )
37
38
  else:
38
39
  raise ValueError(
@@ -41,15 +42,21 @@ class EntityCollection(ClientObjectCollection[T]):
41
42
 
42
43
  def add(self, **kwargs):
43
44
  # type: (Any) -> T
44
- """
45
- Creates an entity and prepares the query
46
- """
45
+ """Creates an entity and prepares the query"""
47
46
  return_type = self.create_typed_object(kwargs, ItemPath(self.resource_path))
48
47
  self.add_child(return_type)
49
48
  qry = CreateEntityQuery(self, return_type, return_type)
50
49
  self.context.add_query(qry)
51
50
  return return_type
52
51
 
52
+ def create_typed_object(self, initial_properties=None, resource_path=None):
53
+ # type: (Optional[dict], Optional[ResourcePath]) -> T
54
+ if resource_path is None:
55
+ resource_path = EntityPath(None, self.resource_path)
56
+ return super(EntityCollection, self).create_typed_object(
57
+ initial_properties, resource_path
58
+ )
59
+
53
60
  @property
54
61
  def context(self):
55
62
  # type: () -> GraphClient
@@ -1,4 +1,5 @@
1
1
  import datetime
2
+ from typing import Optional
2
3
 
3
4
  from office365.entity import Entity
4
5
 
@@ -6,6 +7,9 @@ from office365.entity import Entity
6
7
  class DeviceEnrollmentConfiguration(Entity):
7
8
  """The Base Class of Device Enrollment Configuration"""
8
9
 
10
+ def __str__(self):
11
+ return self.display_name
12
+
9
13
  @property
10
14
  def created_datetime(self):
11
15
  """
@@ -15,10 +19,8 @@ class DeviceEnrollmentConfiguration(Entity):
15
19
 
16
20
  @property
17
21
  def display_name(self):
18
- """
19
- The display name of the device enrollment configuration
20
- :rtype: str
21
- """
22
+ # type: () -> Optional[str]
23
+ """The display name of the device enrollment configuration"""
22
24
  return self.properties.get("displayName", None)
23
25
 
24
26
  def get_property(self, name, default_value=None):
@@ -1,3 +1,5 @@
1
+ from typing import Optional
2
+
1
3
  from office365.entity import Entity
2
4
  from office365.entity_collection import EntityCollection
3
5
  from office365.intune.devices.category import DeviceCategory
@@ -17,12 +19,12 @@ class ManagedDevice(Entity):
17
19
 
18
20
  @property
19
21
  def activation_lock_bypass_code(self):
22
+ # type: () -> Optional[str]
20
23
  """
21
24
  The code that allows the Activation Lock on managed device to be bypassed. Default,
22
25
  is Null (Non-Default property) for this property when returned as part of managedDevice entity in LIST call.
23
26
  To retrieve actual values GET call needs to be made, with device id and included in select parameter.
24
27
  Supports: $select. $Search is not supported. Read-only. This property is read-only.
25
- :rtype: str
26
28
  """
27
29
  return self.properties.get("activationLockBypassCode", None)
28
30
 
@@ -38,25 +40,20 @@ class ManagedDevice(Entity):
38
40
 
39
41
  @property
40
42
  def manufacturer(self):
41
- """
42
- Manufacturer of the device.
43
- :rtype: str
44
- """
43
+ # type: () -> Optional[str]
44
+ """Manufacturer of the device."""
45
45
  return self.properties.get("manufacturer", None)
46
46
 
47
47
  @property
48
48
  def operating_system(self):
49
- """
50
- Manufacturer of the device.
51
- :rtype: str
52
- """
49
+ # type: () -> Optional[str]
50
+ """Manufacturer of the device."""
53
51
  return self.properties.get("operatingSystem", None)
54
52
 
55
53
  @property
56
54
  def device_compliance_policy_states(self):
57
- """
58
- Device compliance policy states for this device
59
- """
55
+ # type: () -> EntityCollection[DeviceCompliancePolicyState]
56
+ """Device compliance policy states for this device"""
60
57
  return self.properties.get(
61
58
  "deviceCompliancePolicyStates",
62
59
  EntityCollection(
@@ -1,4 +1,5 @@
1
1
  from datetime import datetime
2
+ from typing import Optional
2
3
 
3
4
  from office365.entity import Entity
4
5
  from office365.entity_collection import EntityCollection
@@ -38,9 +39,8 @@ class ItemActivityStat(Entity):
38
39
 
39
40
  @property
40
41
  def is_trending(self):
41
- """Indicates whether the item is trending.
42
- :rtype: bool or None
43
- """
42
+ # type: () -> Optional[bool]
43
+ """Indicates whether the item is trending."""
44
44
  return self.properties.get("isTrending", None)
45
45
 
46
46
  @property
@@ -55,6 +55,7 @@ class ItemActivityStat(Entity):
55
55
 
56
56
  @property
57
57
  def activities(self):
58
+ # type: () -> EntityCollection[ItemActivity]
58
59
  """Exposes the itemActivities represented in this itemActivityStat resource."""
59
60
  return self.properties.get(
60
61
  "activities",
@@ -32,6 +32,12 @@ class ColumnDefinition(BaseItem):
32
32
  To list hidden field values on listItems, include the desired columns by name in your $select statement.
33
33
  """
34
34
 
35
+ def __str__(self):
36
+ return self.name
37
+
38
+ def __repr__(self):
39
+ return self.name or self.id or self.entity_type_name
40
+
35
41
  @property
36
42
  def display_name(self):
37
43
  # type: () -> Optional[str]
@@ -41,9 +47,7 @@ class ColumnDefinition(BaseItem):
41
47
  @property
42
48
  def enforce_unique_values(self):
43
49
  # type: () -> Optional[bool]
44
- """
45
- If true, no two list items may have the same value for this column.
46
- """
50
+ """If true, no two list items may have the same value for this column."""
47
51
  return self.properties.get("enforceUniqueValues", None)
48
52
 
49
53
  @property
@@ -145,9 +149,7 @@ class ColumnDefinition(BaseItem):
145
149
  @property
146
150
  def is_reorderable(self):
147
151
  # type: () -> Optional[bool]
148
- """
149
- Indicates whether values in the column can be reordered. Read-only.
150
- """
152
+ """Indicates whether values in the column can be reordered."""
151
153
  return self.properties.get("isReorderable", None)
152
154
 
153
155
  @property
@@ -195,9 +197,7 @@ class ColumnDefinition(BaseItem):
195
197
  @property
196
198
  def type(self):
197
199
  # type: () -> Optional[str]
198
- """
199
- For site columns, the type of column.
200
- """
200
+ """For site columns, the type of column."""
201
201
  return self.properties.get("type", None)
202
202
 
203
203
  def get_property(self, name, default_value=None):
@@ -25,9 +25,7 @@ class DocumentSetVersion(ListItemVersion):
25
25
  @property
26
26
  def created_datetime(self):
27
27
  # type: () -> datetime.datetime
28
- """
29
- Date and time when this version was created.
30
- """
28
+ """Date and time when this version was created."""
31
29
  return self.properties("createdDateTime", datetime.datetime.min)
32
30
 
33
31
  @property
@@ -62,13 +62,30 @@ class DriveItem(BaseItem):
62
62
  """The driveItem resource represents a file, folder, or other item stored in a drive. All file system objects in
63
63
  OneDrive and SharePoint are returned as driveItem resources"""
64
64
 
65
- def get_by_path(self, url_path):
66
- # type: (str) -> "DriveItem"
65
+ def get_files(self, recursive=False):
66
+ """Retrieves files
67
+ :param bool recursive: Determines whether to enumerate folders recursively
67
68
  """
68
- Retrieve DriveItem by server relative path
69
+ return_type = EntityCollection(self.context, DriveItem, self.resource_path)
69
70
 
70
- :type url_path: str
71
- """
71
+ def _get_files(parent_drive_item):
72
+ # type: (DriveItem) -> None
73
+ def _after_loaded():
74
+ for drive_item in parent_drive_item.children:
75
+ if drive_item.is_folder:
76
+ if recursive:
77
+ _get_files(drive_item)
78
+ else:
79
+ return_type.add_child(drive_item)
80
+
81
+ parent_drive_item.ensure_properties(["children"], _after_loaded)
82
+
83
+ _get_files(self)
84
+ return return_type
85
+
86
+ def get_by_path(self, url_path):
87
+ # type: (str) -> "DriveItem"
88
+ """Retrieve DriveItem by server relative path"""
72
89
  return DriveItem(
73
90
  self.context, UrlPath(url_path, self.resource_path), self.children
74
91
  )
@@ -77,7 +94,6 @@ class DriveItem(BaseItem):
77
94
  # type: (str) -> "DriveItem"
78
95
  """
79
96
  Creates a PowerPoint file
80
-
81
97
  :param str name: File name
82
98
  """
83
99
  return self.upload(name, None)
@@ -140,18 +156,14 @@ class DriveItem(BaseItem):
140
156
 
141
157
  def follow(self):
142
158
  # type: () -> Self
143
- """
144
- Follow a driveItem.
145
- """
159
+ """Follow a driveItem."""
146
160
  qry = ServiceOperationQuery(self, "follow")
147
161
  self.context.add_query(qry)
148
162
  return self
149
163
 
150
164
  def unfollow(self):
151
165
  # type: () -> Self
152
- """
153
- Unfollow a driveItem.
154
- """
166
+ """Unfollow a driveItem."""
155
167
  qry = ServiceOperationQuery(self, "unfollow")
156
168
  self.context.add_query(qry)
157
169
  return self
@@ -363,9 +375,7 @@ class DriveItem(BaseItem):
363
375
  return_type = ClientResult(self.context) # type: ClientResult[str]
364
376
 
365
377
  def _create_request(request):
366
- """
367
- :type request: office365.runtime.http.request_options.RequestOptions
368
- """
378
+ # type: (RequestOptions) -> None
369
379
  request.url += "?@microsoft.graph.conflictBehavior={0}".format(
370
380
  conflict_behavior
371
381
  )
@@ -533,14 +543,13 @@ class DriveItem(BaseItem):
533
543
 
534
544
  qry = _create_query()
535
545
  self.context.add_query(qry)
536
-
537
546
  return return_type
538
547
 
539
548
  def permanent_delete(self):
540
549
  """
541
550
  Permanently delete a driveItem.
542
551
  Note that if you delete items using this method, they will be permanently removed and won't be sent to the
543
- recycle bin. Therefore, they cannot be restored afterward.
552
+ recycle bin. Therefore, they cannot be restored afterward. For non-permanent delete, use delete_object()
544
553
  """
545
554
  qry = ServiceOperationQuery(self, "permanentDelete")
546
555
  self.context.add_query(qry)
@@ -583,10 +592,7 @@ class DriveItem(BaseItem):
583
592
 
584
593
  def validate_permission(self, challenge_token=None, password=None):
585
594
  # type: (Optional[str], Optional[str]) -> Self
586
- """
587
- :type challenge_token: str
588
- :type password: str
589
- """
595
+ """ """
590
596
  payload = {"challengeToken": challenge_token, "password": password}
591
597
  qry = ServiceOperationQuery(self, "validatePermission", None, payload)
592
598
  self.context.add_query(qry)
@@ -619,9 +625,7 @@ class DriveItem(BaseItem):
619
625
  @property
620
626
  def location(self):
621
627
  # type: () -> GeoCoordinates
622
- """
623
- Location metadata, if the item has location data. Read-only.
624
- """
628
+ """Location metadata, if the item has location data"""
625
629
  return self.properties.get("location", GeoCoordinates())
626
630
 
627
631
  @property
@@ -664,15 +668,12 @@ class DriveItem(BaseItem):
664
668
  @property
665
669
  def web_dav_url(self):
666
670
  # type: () -> str or None
667
- """
668
- WebDAV compatible URL for the item.
669
- :rtype: str or None
670
- """
671
+ """WebDAV compatible URL for the item."""
671
672
  return self.properties.get("webDavUrl", None)
672
673
 
673
674
  @property
674
675
  def children(self):
675
- # type: () -> EntityCollection[DriveItem]
676
+ # type: () -> EntityCollection["DriveItem"]
676
677
  """Collection containing Item objects for the immediate children of Item. Only items representing folders
677
678
  have children.
678
679
  """
@@ -794,6 +795,12 @@ class DriveItem(BaseItem):
794
795
  ),
795
796
  )
796
797
 
798
+ def set_property(self, name, value, persist_changes=True):
799
+ super(DriveItem, self).set_property(name, value, persist_changes)
800
+ if name == "parentReference":
801
+ self._resource_path.parent.patch(self.parent_reference.driveId)
802
+ return self
803
+
797
804
  def get_property(self, name, default_value=None):
798
805
  # type: (str, P_T) -> P_T
799
806
  if default_value is None:
@@ -1,4 +1,4 @@
1
- from office365.runtime.paths.entity import EntityPath
1
+ from office365.runtime.paths.v4.entity import EntityPath
2
2
 
3
3
 
4
4
  class ChildrenPath(EntityPath):
@@ -13,5 +13,5 @@ class ChildrenPath(EntityPath):
13
13
  if isinstance(self.parent, EntityPath):
14
14
  self._collection = self.parent.collection
15
15
  else:
16
- self._collection = self.parent.parent
16
+ self._collection = self.parent
17
17
  return self._collection
@@ -1,4 +1,4 @@
1
- from office365.runtime.paths.entity import EntityPath
1
+ from office365.runtime.paths.v4.entity import EntityPath
2
2
 
3
3
 
4
4
  class RootPath(EntityPath):
@@ -1,22 +1,27 @@
1
1
  import base64
2
2
 
3
3
  from office365.runtime.paths.resource_path import ResourcePath
4
+ from office365.runtime.paths.v4.entity import EntityPath
4
5
 
5
6
 
6
7
  def _url_to_shared_token(url):
7
- """
8
- Converts url into shared token
9
- :param str url:
10
- """
8
+ # type: (str) -> str
9
+ """Converts url into shared token"""
11
10
  value = base64.b64encode(url.encode("ascii")).decode("ascii")
12
11
  if value.endswith("="):
13
12
  value = value[:-1]
14
13
  return "u!" + value.replace("/", "_").replace("+", "-")
15
14
 
16
15
 
17
- class SharedPath(ResourcePath):
16
+ class SharedPath(EntityPath):
18
17
  """Shared token path"""
19
18
 
19
+ def patch(self, key):
20
+ self._key = "items"
21
+ self._parent = ResourcePath(key, ResourcePath("drives"))
22
+ self.__class__ = ResourcePath
23
+ return self
24
+
20
25
  @property
21
26
  def segment(self):
22
- return _url_to_shared_token(self.key)
27
+ return _url_to_shared_token(self._key)
@@ -1,6 +1,6 @@
1
1
  from office365.runtime.compat import is_absolute_url, urlparse
2
- from office365.runtime.paths.entity import EntityPath
3
2
  from office365.runtime.paths.resource_path import ResourcePath
3
+ from office365.runtime.paths.v4.entity import EntityPath
4
4
 
5
5
 
6
6
  class SitePath(EntityPath):
@@ -8,8 +8,8 @@ class SitePath(EntityPath):
8
8
 
9
9
  @property
10
10
  def segment(self):
11
- if is_absolute_url(self.key):
12
- url_result = urlparse(self.key)
11
+ if is_absolute_url(self._key):
12
+ url_result = urlparse(self._key)
13
13
  return ":".join([url_result.hostname, url_result.path])
14
14
  else:
15
15
  return super(SitePath, self).segment
@@ -1,5 +1,5 @@
1
1
  from office365.onedrive.internal.paths.root import RootPath
2
- from office365.runtime.paths.entity import EntityPath
2
+ from office365.runtime.paths.v4.entity import EntityPath
3
3
 
4
4
 
5
5
  class UrlPath(EntityPath):
@@ -11,7 +11,7 @@ class UrlPath(EntityPath):
11
11
  :type parent: office365.runtime.paths.resource_path.ResourcePath
12
12
  """
13
13
  if isinstance(parent, UrlPath):
14
- url = "/".join([parent.key, url])
14
+ url = "/".join([parent._key, url])
15
15
  collection = parent.collection
16
16
  parent = parent.parent
17
17
  elif isinstance(parent, RootPath):
@@ -60,6 +60,7 @@ class ListItem(BaseItem):
60
60
 
61
61
  @property
62
62
  def content_type(self):
63
+ # type: () -> ContentTypeInfo
63
64
  """The content type of this list item"""
64
65
  return self.properties.get("contentType", ContentTypeInfo())
65
66
 
@@ -73,6 +74,7 @@ class ListItem(BaseItem):
73
74
 
74
75
  @property
75
76
  def document_set_versions(self):
77
+ # type: () -> EntityCollection[DocumentSetVersion]
76
78
  """Version information for a document set version created by a user."""
77
79
  return self.properties.get(
78
80
  "documentSetVersions",
@@ -1,3 +1,5 @@
1
+ from typing import Optional
2
+
1
3
  from office365.base_item import BaseItem
2
4
  from office365.entity_collection import EntityCollection
3
5
  from office365.onedrive.columns.definition_collection import ColumnDefinitionCollection
@@ -14,12 +16,13 @@ class List(BaseItem):
14
16
  """The list resource represents a list in a site. This resource contains the top level properties of the list,
15
17
  including template and field definitions."""
16
18
 
19
+ def __str__(self):
20
+ return self.display_name
21
+
17
22
  @property
18
23
  def display_name(self):
19
- """
20
- The displayable title of the list
21
- :rtype: str or None
22
- """
24
+ # type: () -> Optional[str]
25
+ """The displayable title of the list"""
23
26
  return self.properties.get("displayName", None)
24
27
 
25
28
  @property