Office365-REST-Python-Client 2.5.2__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 (124) hide show
  1. {Office365_REST_Python_Client-2.5.2.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/METADATA +4 -4
  2. {Office365_REST_Python_Client-2.5.2.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/RECORD +122 -119
  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/audit/signins/signin.py +8 -12
  9. office365/directory/authentication/methods/details.py +8 -6
  10. office365/directory/groups/lifecycle_policy.py +8 -7
  11. office365/directory/identities/provider.py +5 -6
  12. office365/directory/internal/paths/me.py +1 -1
  13. office365/directory/permissions/email_identity.py +7 -0
  14. office365/directory/rolemanagement/role.py +5 -4
  15. office365/directory/rolemanagement/template.py +2 -6
  16. office365/directory/rolemanagement/unified_role_assignment.py +5 -4
  17. office365/directory/rolemanagement/unified_role_definition.py +6 -4
  18. office365/directory/serviceprincipals/service_principal.py +11 -6
  19. office365/directory/users/user.py +8 -11
  20. office365/entity.py +2 -2
  21. office365/entity_collection.py +11 -4
  22. office365/intune/devices/enrollment/configuration.py +6 -4
  23. office365/intune/devices/managed.py +9 -12
  24. office365/onedrive/analytics/item_activity_stat.py +4 -3
  25. office365/onedrive/columns/definition.py +9 -9
  26. office365/onedrive/documentsets/version.py +1 -3
  27. office365/onedrive/driveitems/driveItem.py +30 -29
  28. office365/onedrive/internal/paths/children.py +2 -2
  29. office365/onedrive/internal/paths/root.py +1 -1
  30. office365/onedrive/internal/paths/shared.py +1 -1
  31. office365/onedrive/internal/paths/site.py +3 -3
  32. office365/onedrive/internal/paths/url.py +2 -2
  33. office365/onedrive/listitems/list_item.py +2 -0
  34. office365/onedrive/lists/list.py +7 -4
  35. office365/onedrive/permissions/collection.py +26 -6
  36. office365/onedrive/sharepoint.py +1 -0
  37. office365/onedrive/shares/collection.py +2 -5
  38. office365/onedrive/shares/drive_item.py +3 -0
  39. office365/onedrive/termstore/groups/collection.py +3 -8
  40. office365/onedrive/termstore/groups/group.py +8 -0
  41. office365/onedrive/termstore/sets/collection.py +2 -6
  42. office365/onedrive/termstore/sets/name.py +5 -0
  43. office365/onedrive/termstore/sets/set.py +7 -0
  44. office365/onedrive/termstore/store.py +10 -13
  45. office365/onedrive/versions/drive_item.py +3 -1
  46. office365/onedrive/workbooks/ranges/range.py +9 -13
  47. office365/onedrive/workbooks/ranges/view.py +1 -0
  48. office365/onedrive/workbooks/tables/table.py +1 -3
  49. office365/onedrive/workbooks/worksheets/worksheet.py +5 -3
  50. office365/onenote/pages/collection.py +3 -2
  51. office365/onenote/resources/resource.py +5 -4
  52. office365/onenote/sectiongroups/section_group.py +10 -7
  53. office365/outlook/calendar/calendar.py +1 -1
  54. office365/outlook/calendar/schedule/information.py +0 -1
  55. office365/outlook/contacts/contact.py +3 -9
  56. office365/outlook/contacts/folder.py +3 -0
  57. office365/outlook/mail/messages/message.py +25 -18
  58. office365/outlook/mail/recipient.py +3 -1
  59. office365/runtime/auth/authentication_context.py +2 -2
  60. office365/runtime/auth/providers/acs_token_provider.py +7 -9
  61. office365/runtime/client_object.py +3 -11
  62. office365/runtime/client_object_collection.py +22 -20
  63. office365/runtime/client_result.py +1 -3
  64. office365/runtime/client_value_collection.py +2 -6
  65. office365/runtime/odata/query_options.py +1 -3
  66. office365/runtime/odata/type.py +2 -0
  67. office365/runtime/paths/appid.py +1 -1
  68. office365/runtime/{odata/url_builder.py → paths/builder.py} +24 -9
  69. office365/runtime/paths/item.py +1 -1
  70. office365/runtime/paths/resource_path.py +12 -16
  71. office365/runtime/paths/service_operation.py +8 -7
  72. office365/runtime/paths/v3/__init__.py +0 -0
  73. office365/runtime/paths/{key.py → v3/entity.py} +5 -5
  74. office365/runtime/paths/v4/__init__.py +0 -0
  75. office365/runtime/paths/{entity.py → v4/entity.py} +13 -11
  76. office365/sharepoint/contenttypes/content_type.py +6 -0
  77. office365/sharepoint/documentmanagement/document_set.py +4 -6
  78. office365/sharepoint/entity_collection.py +9 -0
  79. office365/sharepoint/features/feature.py +6 -8
  80. office365/sharepoint/files/checked_out_file.py +4 -2
  81. office365/sharepoint/files/checked_out_file_collection.py +1 -1
  82. office365/sharepoint/files/collection.py +35 -3
  83. office365/sharepoint/files/file.py +35 -11
  84. office365/sharepoint/files/versions/collection.py +4 -0
  85. office365/sharepoint/files/versions/event.py +6 -3
  86. office365/sharepoint/files/versions/version.py +6 -4
  87. office365/sharepoint/folders/collection.py +2 -2
  88. office365/sharepoint/folders/folder.py +5 -11
  89. office365/sharepoint/internal/paths/static_operation.py +9 -0
  90. office365/sharepoint/internal/paths/web.py +20 -0
  91. office365/sharepoint/listitems/collection.py +4 -0
  92. office365/sharepoint/listitems/listitem.py +19 -30
  93. office365/sharepoint/lists/list.py +44 -60
  94. office365/sharepoint/portal/groups/service.py +12 -16
  95. office365/sharepoint/portal/groups/site_manager.py +0 -1
  96. office365/sharepoint/publishing/pages/metadata.py +7 -2
  97. office365/sharepoint/publishing/pages/metadata_collection.py +0 -1
  98. office365/sharepoint/publishing/pages/page.py +3 -6
  99. office365/sharepoint/publishing/pages/reposts/repost.py +5 -9
  100. office365/sharepoint/recyclebin/item.py +11 -9
  101. office365/sharepoint/sharing/links/share_response.py +3 -0
  102. office365/sharepoint/sharing/result.py +18 -41
  103. office365/sharepoint/sites/site.py +46 -68
  104. office365/sharepoint/taxonomy/item.py +4 -2
  105. office365/sharepoint/taxonomy/stores/store.py +2 -6
  106. office365/sharepoint/tenant/administration/internal/permission_grant.py +7 -0
  107. office365/sharepoint/tenant/administration/sites/properties.py +55 -44
  108. office365/sharepoint/tenant/administration/tenant.py +25 -40
  109. office365/sharepoint/usercustomactions/collection.py +0 -1
  110. office365/sharepoint/webs/collection.py +8 -0
  111. office365/sharepoint/webs/template_collection.py +2 -4
  112. office365/sharepoint/webs/web.py +27 -24
  113. office365/teams/apps/app.py +1 -0
  114. office365/teams/collection.py +12 -16
  115. office365/teams/members/conversation_collection.py +1 -3
  116. office365/teams/operations/async_operation.py +3 -5
  117. office365/teams/schedule/groups/group.py +3 -0
  118. office365/teams/team.py +1 -1
  119. office365/todo/attachments/base.py +7 -9
  120. office365/runtime/odata/path_builder.py +0 -23
  121. office365/sharepoint/internal/key_value.py +0 -28
  122. {Office365_REST_Python_Client-2.5.2.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/LICENSE +0 -0
  123. {Office365_REST_Python_Client-2.5.2.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/WHEEL +0 -0
  124. {Office365_REST_Python_Client-2.5.2.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/top_level.txt +0 -0
@@ -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
  """
@@ -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):
@@ -19,4 +19,4 @@ class SharedPath(ResourcePath):
19
19
 
20
20
  @property
21
21
  def segment(self):
22
- return _url_to_shared_token(self.key)
22
+ 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
@@ -1,9 +1,17 @@
1
+ from typing import TYPE_CHECKING
2
+
1
3
  from office365.directory.permissions.identity import Identity
2
4
  from office365.entity import Entity
3
5
  from office365.entity_collection import EntityCollection
4
6
  from office365.onedrive.permissions.permission import Permission
5
7
  from office365.runtime.queries.create_entity import CreateEntityQuery
6
8
 
9
+ if TYPE_CHECKING:
10
+ from office365.directory.applications.application import Application
11
+ from office365.directory.groups.group import Group
12
+ from office365.directory.users.user import User
13
+ from office365.intune.devices.device import Device
14
+
7
15
 
8
16
  class PermissionCollection(EntityCollection[Permission]):
9
17
  """Permission's collection"""
@@ -12,6 +20,7 @@ class PermissionCollection(EntityCollection[Permission]):
12
20
  super(PermissionCollection, self).__init__(context, Permission, resource_path)
13
21
 
14
22
  def add(self, roles, identity=None, identity_type=None):
23
+ # type: (list[str], Application|User|Group|Device|str, str) -> Permission
15
24
  """
16
25
  Create a new permission object.
17
26
 
@@ -21,6 +30,7 @@ class PermissionCollection(EntityCollection[Permission]):
21
30
  """
22
31
 
23
32
  return_type = Permission(self.context)
33
+ self.add_child(return_type)
24
34
 
25
35
  known_identities = {
26
36
  "application": self.context.applications,
@@ -41,7 +51,7 @@ class PermissionCollection(EntityCollection[Permission]):
41
51
  raise ValueError("Unknown identity type")
42
52
  identity = known_identity[identity]
43
53
 
44
- def _create():
54
+ def _add():
45
55
  payload = {
46
56
  "roles": roles,
47
57
  "grantedToIdentities": [
@@ -53,17 +63,27 @@ class PermissionCollection(EntityCollection[Permission]):
53
63
  ],
54
64
  }
55
65
 
56
- self.add_child(return_type)
57
66
  qry = CreateEntityQuery(self, payload, return_type)
58
67
  self.context.add_query(qry)
59
68
 
60
- identity.ensure_properties(["displayName"], _create)
69
+ identity.ensure_properties(["displayName"], _add)
61
70
  return return_type
62
71
 
72
+ def delete(self, roles, identity):
73
+ # type: (list[str], Application|User|Group|Device) -> Permission
74
+ """Deletes the permission."""
75
+
76
+ def _delete(col):
77
+ pass
78
+
79
+ def _identity_loaded():
80
+ self.get_all(page_loaded=_delete)
81
+
82
+ identity.ensure_property("id", _identity_loaded)
83
+ return self
84
+
63
85
  def delete_all(self):
64
- """
65
- Remove all access to resource
66
- """
86
+ """Remove all access to resource"""
67
87
 
68
88
  def _after_loaded(return_type):
69
89
  # type: (PermissionCollection) -> None
@@ -8,6 +8,7 @@ class Sharepoint(Entity):
8
8
 
9
9
  @property
10
10
  def settings(self):
11
+ # type: () -> SharepointSettings
11
12
  """Represents the tenant-level settings for SharePoint and OneDrive."""
12
13
  return self.properties.get(
13
14
  "settings",
@@ -8,9 +8,6 @@ class SharesCollection(EntityCollection[SharedDriveItem]):
8
8
  super(SharesCollection, self).__init__(context, SharedDriveItem, resource_path)
9
9
 
10
10
  def by_url(self, url):
11
- """
12
- Address shared item by absolute url
13
-
14
- :type url: str
15
- """
11
+ # type: (str) -> SharedDriveItem
12
+ """Address shared item by absolute url"""
16
13
  return SharedDriveItem(self.context, SharedPath(url, self.resource_path))
@@ -26,6 +26,7 @@ class SharedDriveItem(BaseItem):
26
26
 
27
27
  @property
28
28
  def list_item(self):
29
+ # type: () -> ListItem
29
30
  """Used to access the underlying listItem"""
30
31
  return self.properties.get(
31
32
  "listItem",
@@ -34,6 +35,7 @@ class SharedDriveItem(BaseItem):
34
35
 
35
36
  @property
36
37
  def list(self):
38
+ # type: () -> List
37
39
  """Used to access the underlying list"""
38
40
  return self.properties.get(
39
41
  "list", List(self.context, ResourcePath("list", self.resource_path))
@@ -41,6 +43,7 @@ class SharedDriveItem(BaseItem):
41
43
 
42
44
  @property
43
45
  def drive_item(self):
46
+ # type: () -> DriveItem
44
47
  """Used to access the underlying driveItem"""
45
48
  return self.properties.get(
46
49
  "driveItem",
@@ -2,24 +2,19 @@ from office365.entity_collection import EntityCollection
2
2
  from office365.onedrive.termstore.groups.group import Group
3
3
 
4
4
 
5
- class GroupCollection(EntityCollection):
5
+ class GroupCollection(EntityCollection[Group]):
6
6
  def __init__(self, context, resource_path=None):
7
7
  super(GroupCollection, self).__init__(context, Group, resource_path)
8
8
 
9
9
  def add(self, display_name):
10
10
  """
11
11
  Create a new group object in a term store.
12
-
13
12
  :param str display_name: Name of the group to be created.
14
- :rtype: Group
15
13
  """
16
14
  props = {"displayName": display_name}
17
15
  return super(GroupCollection, self).add(**props)
18
16
 
19
17
  def get_by_name(self, name):
20
- """Returns the group with the specified name.
21
-
22
- :param str name: Group name
23
- :rtype: Group
24
- """
18
+ # type: (str) -> Group
19
+ """Returns the group with the specified name."""
25
20
  return self.single("displayName eq '{0}'".format(name))