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,3 +1,5 @@
1
+ from typing import Optional
2
+
1
3
  from office365.runtime.paths.resource_path import ResourcePath
2
4
  from office365.sharepoint.entity import Entity
3
5
  from office365.sharepoint.translation.user_resource import UserResource
@@ -9,6 +11,12 @@ class NavigationNode(Entity):
9
11
  manipulating the ordering of the navigation node in a navigation node collection.
10
12
  """
11
13
 
14
+ def __str__(self):
15
+ return self.title
16
+
17
+ def __repr__(self):
18
+ return self.url
19
+
12
20
  @property
13
21
  def children(self):
14
22
  """Gets the collection of child nodes of the navigation node."""
@@ -25,10 +33,8 @@ class NavigationNode(Entity):
25
33
 
26
34
  @property
27
35
  def title(self):
28
- """Gets a value that specifies the anchor text for the navigation node link.
29
-
30
- :rtype: str
31
- """
36
+ # type: () -> Optional[str]
37
+ """Gets a value that specifies the anchor text for the navigation node link."""
32
38
  return self.properties.get("Title", None)
33
39
 
34
40
  @title.setter
@@ -38,10 +44,8 @@ class NavigationNode(Entity):
38
44
 
39
45
  @property
40
46
  def url(self):
41
- """Gets a value that specifies the URL stored with the navigation node.
42
-
43
- :rtype: str
44
- """
47
+ # type: () -> Optional[str]
48
+ """Gets a value that specifies the URL stored with the navigation node."""
45
49
  return self.properties.get("Url", None)
46
50
 
47
51
  @url.setter
@@ -51,17 +55,14 @@ class NavigationNode(Entity):
51
55
 
52
56
  @property
53
57
  def is_visible(self):
54
- """Gets a value that specifies the anchor text for the navigation node link.
55
-
56
- :rtype: bool or None
57
- """
58
+ # type: () -> Optional[bool]
59
+ """Gets a value that specifies the anchor text for the navigation node link."""
58
60
  return self.properties.get("isVisible", None)
59
61
 
60
62
  @property
61
63
  def is_external(self):
62
- """
63
- :rtype: bool or None
64
- """
64
+ # type: () -> Optional[bool]
65
+ """ """
65
66
  return self.properties.get("isExternal", None)
66
67
 
67
68
  @property
@@ -1,21 +1,27 @@
1
+ from typing import TYPE_CHECKING
2
+
1
3
  from office365.runtime.paths.service_operation import ServiceOperationPath
2
4
  from office365.runtime.queries.create_entity import CreateEntityQuery
3
5
  from office365.runtime.queries.service_operation import ServiceOperationQuery
4
6
  from office365.sharepoint.entity_collection import EntityCollection
5
7
  from office365.sharepoint.navigation.node import NavigationNode
6
8
 
9
+ if TYPE_CHECKING:
10
+ from office365.sharepoint.navigation.node_creation_information import (
11
+ NavigationNodeCreationInformation, # noqa
12
+ )
13
+
7
14
 
8
- class NavigationNodeCollection(EntityCollection):
15
+ class NavigationNodeCollection(EntityCollection[NavigationNode]):
9
16
  def __init__(self, context, resource_path=None):
10
17
  super(NavigationNodeCollection, self).__init__(
11
18
  context, NavigationNode, resource_path
12
19
  )
13
20
 
14
21
  def add(self, create_node_info):
22
+ # type: (NavigationNodeCreationInformation) -> NavigationNode
15
23
  """
16
24
  Creates a navigation node object and adds it to the collection.
17
-
18
- :type create_node_info: office365.sharepoint.navigation.node_creation_information.NavigationNodeCreationInformation
19
25
  """
20
26
  return_type = NavigationNode(self.context)
21
27
  return_type.title = create_node_info.Title
@@ -1,4 +1,5 @@
1
1
  import inspect
2
+ from typing import Iterator
2
3
 
3
4
  from office365.runtime.client_value import ClientValue
4
5
  from office365.sharepoint.permissions.kind import PermissionKind
@@ -12,9 +13,15 @@ class BasePermissions(ClientValue):
12
13
  self.High = 0
13
14
  self.Low = 0
14
15
 
16
+ def __iter__(self):
17
+ # type: () -> Iterator[str]
18
+ for k, v in inspect.getmembers(PermissionKind):
19
+ if isinstance(v, int) and self.has(v):
20
+ yield k
21
+
15
22
  def set(self, perm):
16
23
  """
17
-
24
+ Assigns the permission
18
25
  :type perm: int
19
26
  """
20
27
  if perm == PermissionKind.FullMask:
@@ -34,6 +41,7 @@ class BasePermissions(ClientValue):
34
41
  self.High |= low << high - 32
35
42
 
36
43
  def has(self, perm):
44
+ # type: (int) -> bool
37
45
  """Determines whether the current instance has the specified permission."""
38
46
  if perm == PermissionKind.EmptyMask:
39
47
  return True
@@ -59,8 +67,5 @@ class BasePermissions(ClientValue):
59
67
 
60
68
  @property
61
69
  def permission_levels(self):
62
- result = []
63
- for k, v in inspect.getmembers(PermissionKind):
64
- if isinstance(v, int) and self.has(v):
65
- result.append(k)
66
- return result
70
+ """Gets permission levels"""
71
+ return list(self)
@@ -5,7 +5,7 @@ from office365.sharepoint.entity_collection import EntityCollection
5
5
  from office365.sharepoint.permissions.roles.assignments.assignment import RoleAssignment
6
6
 
7
7
 
8
- class RoleAssignmentCollection(EntityCollection):
8
+ class RoleAssignmentCollection(EntityCollection[RoleAssignment]):
9
9
  """Represents a collection of RoleAssignment resources."""
10
10
 
11
11
  def __init__(self, context, resource_path=None):
@@ -13,18 +13,14 @@ class RoleAssignmentCollection(EntityCollection):
13
13
  context, RoleAssignment, resource_path
14
14
  )
15
15
 
16
- def __getitem__(self, index_or_principal_id):
16
+ def __getitem__(self, key):
17
17
  """
18
- :param int or str index_or_principal_id: key is used to address a RoleAssignment resource by either an index
18
+ :param int or str key: key is used to address a RoleAssignment resource by either an index
19
19
  in collection or by resource id"""
20
- if type(index_or_principal_id) == int:
21
- return super(RoleAssignmentCollection, self).__getitem__(
22
- index_or_principal_id
23
- )
20
+ if isinstance(key, int):
21
+ return super(RoleAssignmentCollection, self).__getitem__(key)
24
22
  else:
25
- return self._item_type(
26
- self.context, ResourcePath(index_or_principal_id, self.resource_path)
27
- )
23
+ return self._item_type(self.context, ResourcePath(key, self.resource_path))
28
24
 
29
25
  def get_by_principal_id(self, principal_id):
30
26
  """Retrieves the role assignment object (1) based on the specified user or group.
@@ -39,10 +35,10 @@ class RoleAssignmentCollection(EntityCollection):
39
35
  )
40
36
 
41
37
  def add_role_assignment(self, principal_id, role_def_id):
42
- """Adds a role assignment to the role assignment collection.<81>
38
+ """Adds a role assignment to the role assignment collection.
43
39
 
44
- :param int role_def_id: Specifies the role definition of the role assignment.
45
40
  :param int principal_id: Specifies the user or group of the role assignment.
41
+ :param int role_def_id: Specifies the role definition of the role assignment.
46
42
  """
47
43
  payload = {"principalId": principal_id, "roleDefId": role_def_id}
48
44
  qry = ServiceOperationQuery(
@@ -9,7 +9,7 @@ class RoleDefinition(Entity):
9
9
  """Defines a single role definition, including a name, description, and set of rights."""
10
10
 
11
11
  def __repr__(self):
12
- return self.name
12
+ return self.name or self.entity_type_name
13
13
 
14
14
  @property
15
15
  def base_permissions(self):
@@ -22,12 +22,14 @@ class RoleDefinition(Entity):
22
22
 
23
23
  @property
24
24
  def id(self):
25
+ # type: () -> Optional[int]
25
26
  """Specifies the identifier of the role definition.
26
27
  Its value MUST be equal to or greater than 1073741824."""
27
28
  return self.properties.get("Id", None)
28
29
 
29
30
  @property
30
31
  def role_type_kind(self):
32
+ # type: () -> Optional[int]
31
33
  """Specifies the type of the role definition.
32
34
  Its value MUST be equal to or greater than 0. Its value MUST be equal to or less than 5.
33
35
  """
@@ -1,3 +1,5 @@
1
+ from typing import Optional
2
+
1
3
  from typing_extensions import Self
2
4
 
3
5
  from office365.runtime.client_result import ClientResult
@@ -33,41 +35,50 @@ class SecurableObject(Entity):
33
35
  principal.ensure_property("Id", _principal_loaded)
34
36
  return return_type
35
37
 
36
- def add_role_assignment(self, principal, role_def):
37
- # type: (Principal, RoleDefinition) -> Self
38
+ def add_role_assignment(self, principal, role):
39
+ # type: (Principal|str, RoleDefinition|int) -> Self
38
40
  """Adds a role assignment to securable resource.
39
41
 
40
- :param office365.sharepoint.permissions.roles.definitions.definition.RoleDefinition role_def: Specifies the
41
- role definition of the role assignment.
42
- :param office365.sharepoint.principal.principal.Principal principal: Specifies the user or group of the
43
- role assignment.
42
+ :param RoleDefinition or int principal: Specifies the role definition or role type.
43
+ :param Principal or str role: Specifies the user or group of the role assignment.
44
44
  """
45
45
 
46
- def _principal_loaded():
47
- role_def.ensure_property("Id", _role_def_loaded)
46
+ if not isinstance(principal, Principal):
47
+ principal = self.context.web.site_users.get_by_principal_name(principal)
48
48
 
49
- def _role_def_loaded():
50
- self.role_assignments.add_role_assignment(principal.id, role_def.id)
49
+ if not isinstance(role, RoleDefinition):
50
+ role = self.context.web.role_definitions.get_by_type(role)
51
51
 
52
- principal.ensure_property("Id", _principal_loaded)
52
+ def _ensure_role_def():
53
+ role.ensure_property("Id", _add_role_assignment)
54
+
55
+ def _add_role_assignment():
56
+ self.role_assignments.add_role_assignment(principal.id, role.id)
57
+
58
+ principal.ensure_property("Id", _ensure_role_def)
53
59
  return self
54
60
 
55
61
  def remove_role_assignment(self, principal, role_def):
56
- """Removes a role assignment from a securable resource.<81>
57
-
58
- :param office365.sharepoint.permissions.role_definition.RoleDefinition role_def: Specifies the role definition
59
- of the role assignment.
60
- :param office365.sharepoint.principal.principal.Principal principal: Specifies the user or group of the
62
+ # type: (Principal|str, RoleDefinition|int) -> Self
63
+ """Removes a role assignment from a securable resource.
64
+ :param Principal principal: Specifies the user or group of the
61
65
  role assignment.
66
+ :param RoleDefinition role_def: Specifies the role definition
67
+ of the role assignment.
62
68
  """
69
+ if not isinstance(principal, Principal):
70
+ principal = self.context.web.site_users.get_by_principal_name(principal)
63
71
 
64
- def _principal_loaded():
65
- def _role_def_loaded():
66
- self.role_assignments.remove_role_assignment(principal.id, role_def.id)
72
+ if not isinstance(role_def, RoleDefinition):
73
+ role_def = self.context.web.role_definitions.get_by_type(role_def)
67
74
 
68
- role_def.ensure_property("Id", _role_def_loaded)
75
+ def _remove_role_assignment():
76
+ self.role_assignments.remove_role_assignment(principal.id, role_def.id)
69
77
 
70
- principal.ensure_property("Id", _principal_loaded)
78
+ def _ensure_role_def():
79
+ role_def.ensure_property("Id", _remove_role_assignment)
80
+
81
+ principal.ensure_property("Id", _ensure_role_def)
71
82
  return self
72
83
 
73
84
  def break_role_inheritance(self, copy_role_assignments=True, clear_sub_scopes=True):
@@ -110,19 +121,16 @@ class SecurableObject(Entity):
110
121
  return self
111
122
 
112
123
  def get_user_effective_permissions(self, user):
124
+ # type: (str|User) -> ClientResult[BasePermissions]
113
125
  """
114
- Returns the user permissions for this list.
126
+ Returns the user permissions for secured object.
115
127
 
116
128
  :param str or User user: Specifies the user login name or User object.
117
129
  """
118
- return_type = ClientResult(
119
- self.context, BasePermissions()
120
- ) # type: ClientResult[BasePermissions]
130
+ return_type = ClientResult(self.context, BasePermissions())
121
131
 
122
132
  def _create_and_add_query(login_name):
123
- """
124
- :param str login_name:
125
- """
133
+ # type: (str) -> None
126
134
  qry = ServiceOperationQuery(
127
135
  self,
128
136
  "GetUserEffectivePermissions",
@@ -145,17 +153,16 @@ class SecurableObject(Entity):
145
153
 
146
154
  @property
147
155
  def has_unique_role_assignments(self):
156
+ # type: () -> Optional[bool]
148
157
  """Specifies whether the role assignments are uniquely defined for this securable object or inherited from a
149
158
  parent securable object. If the value is "false", role assignments are inherited from a parent securable
150
159
  object.
151
-
152
- :rtype: bool or None
153
160
  """
154
161
  return self.properties.get("HasUniqueRoleAssignments", None)
155
162
 
156
163
  @property
157
164
  def first_unique_ancestor_securable_object(self):
158
- """Specifies the object where role assignments for this object are defined.<85>."""
165
+ """Specifies the object where role assignments for this object are defined"""
159
166
  return self.properties.get(
160
167
  "FirstUniqueAncestorSecurableObject",
161
168
  SecurableObject(
@@ -1,40 +1,36 @@
1
1
  import random
2
+ from typing import AnyStr
2
3
 
3
4
  from office365.runtime.client_result import ClientResult
4
5
  from office365.runtime.http.http_method import HttpMethod
6
+ from office365.runtime.http.request_options import RequestOptions
5
7
  from office365.runtime.queries.service_operation import ServiceOperationQuery
6
8
  from office365.sharepoint.entity import Entity
7
9
 
8
10
 
9
11
  class GroupService(Entity):
10
- def __init__(self, context, resource_path=None):
11
- super(GroupService, self).__init__(context, resource_path)
12
-
13
- def get_group_image(self, group_id, image_hash=None, image_color=None):
14
- """
15
- :param str group_id:
16
- :param int or None image_hash:
17
- :param str or None image_color:
18
- """
19
- return_type = ClientResult(self.context)
12
+ def get_group_image(
13
+ self, group_id, image_hash=None, image_color=None, return_type=None
14
+ ):
15
+ # type: (str, str, str, ClientResult) -> ClientResult[AnyStr]
16
+ if return_type is None:
17
+ return_type = ClientResult(self.context)
20
18
  if image_hash is None:
21
19
  image_hash = random.getrandbits(64)
22
20
  qry = ServiceOperationQuery(
23
21
  self, "GetGroupImage", None, None, None, return_type
24
22
  )
25
23
 
26
- def _modify_request(request):
27
- """
28
- :type request: office365.runtime.http.request_options.RequestOptions
29
- """
24
+ def _create_request(request):
25
+ # type: (RequestOptions) -> None
30
26
  request.url += "?id='{0}'&hash={1}".format(group_id, image_hash)
31
27
  request.method = HttpMethod.Get
32
28
 
33
- self.context.before_execute(_modify_request)
34
- self.context.add_query(qry)
29
+ self.context.add_query(qry).before_execute(_create_request)
35
30
  return return_type
36
31
 
37
32
  def sync_group_properties(self):
33
+ """ """
38
34
  qry = ServiceOperationQuery(self, "SyncGroupProperties")
39
35
  self.context.add_query(qry)
40
36
  return self
@@ -120,7 +120,6 @@ class GroupSiteManager(ClientObject):
120
120
  ):
121
121
  """
122
122
  Get the teams in Microsoft Teams that the current user is a direct member of.
123
-
124
123
  :type get_logo_data: bool
125
124
  :type force_cache_update: bool
126
125
  """
@@ -1,3 +1,5 @@
1
+ from typing import TYPE_CHECKING, Optional
2
+
1
3
  from office365.runtime.client_result import ClientResult
2
4
  from office365.runtime.client_value_collection import ClientValueCollection
3
5
  from office365.runtime.paths.resource_path import ResourcePath
@@ -5,6 +7,9 @@ from office365.runtime.queries.service_operation import ServiceOperationQuery
5
7
  from office365.sharepoint.principal.principal import Principal
6
8
  from office365.sharepoint.utilities.principal_info import PrincipalInfo
7
9
 
10
+ if TYPE_CHECKING:
11
+ from office365.sharepoint.principal.groups.collection import GroupCollection
12
+
8
13
 
9
14
  class Group(Principal):
10
15
  """Represents a collection of members in a SharePoint site. A group is a type of SP.Principal."""
@@ -67,72 +72,61 @@ class Group(Principal):
67
72
 
68
73
  @property
69
74
  def parent_collection(self):
70
- """
71
- :rtype: office365.sharepoint.principal.groups.collection.GroupCollection
72
- """
75
+ # type: () -> GroupCollection
73
76
  return self._parent_collection
74
77
 
75
78
  @property
76
79
  def allow_members_edit_membership(self):
77
- """Specifies whether a member of the group can add and remove members from the group.
78
- :rtype: bool or None
79
- """
80
+ # type: () -> Optional[bool]
81
+ """Specifies whether a member of the group can add and remove members from the group"""
80
82
  return self.properties.get("AllowMembersEditMembership", None)
81
83
 
82
84
  @property
83
85
  def allow_request_to_join_leave(self):
84
- """Specifies whether to allow users to request to join or leave in the group.
85
- :rtype: bool or None
86
- """
86
+ # type: () -> Optional[bool]
87
+ """Specifies whether to allow users to request to join or leave in the group."""
87
88
  return self.properties.get("AllowRequestToJoinLeave", None)
88
89
 
89
90
  @property
90
91
  def auto_accept_request_to_join_leave(self):
91
- """Specifies whether requests to join or leave the group are automatically accepted.
92
- :rtype: bool or None
93
- """
92
+ # type: () -> Optional[bool]
93
+ """Specifies whether requests to join or leave the group are automatically accepted"""
94
94
  return self.properties.get("AutoAcceptRequestToJoinLeave", None)
95
95
 
96
96
  @property
97
97
  def can_current_user_edit_membership(self):
98
- """Specifies whether the current user can add and remove members from the group.
99
- :rtype: bool or None
100
- """
98
+ # type: () -> Optional[bool]
99
+ """Specifies whether the current user can add and remove members from the group."""
101
100
  return self.properties.get("CanCurrentUserEditMembership", None)
102
101
 
103
102
  @property
104
103
  def can_current_user_manage_group(self):
105
- """Gets a Boolean value that indicates whether the current user can manage the group.
106
- :rtype: bool or None
107
- """
104
+ # type: () -> Optional[bool]
105
+ """Gets a Boolean value that indicates whether the current user can manage the group."""
108
106
  return self.properties.get("CanCurrentUserManageGroup", None)
109
107
 
110
108
  @property
111
109
  def can_current_user_view_membership(self):
112
- """Specifies whether the current user can view the membership of the group.
113
- :rtype: bool or None
114
- """
110
+ # type: () -> Optional[bool]
111
+ """Specifies whether the current user can view the membership of the group."""
115
112
  return self.properties.get("CanCurrentUserViewMembership", None)
116
113
 
117
114
  @property
118
115
  def only_allow_members_view_membership(self):
119
- """Specifies whether viewing the membership of the group is restricted to members of the group.
120
- :rtype: bool or None
121
- """
116
+ # type: () -> Optional[bool]
117
+ """Specifies whether viewing the membership of the group is restricted to members of the group."""
122
118
  return self.properties.get("OnlyAllowMembersViewMembership", None)
123
119
 
124
120
  @property
125
121
  def owner_title(self):
126
- """Specifies the name of the owner of the group.
127
- :rtype: str or None
128
- """
122
+ # type: () -> Optional[str]
123
+ """Specifies the name of the owner of the group."""
129
124
  return self.properties.get("OwnerTitle", None)
130
125
 
131
126
  @property
132
127
  def request_to_join_leave_email_setting(self):
133
- """Specifies the e-mail address to which requests to join or leave the group are sent.
134
- :rtype: str or None
135
- """
128
+ # type: () -> Optional[str]
129
+ """Specifies the e-mail address to which requests to join or leave the group are sent."""
136
130
  return self.properties.get("RequestToJoinLeaveEmailSetting", None)
137
131
 
138
132
  @property
@@ -1,3 +1,5 @@
1
+ from typing import Optional
2
+
1
3
  from office365.runtime.paths.service_operation import ServiceOperationPath
2
4
  from office365.sharepoint.entity import Entity
3
5
 
@@ -5,54 +7,54 @@ from office365.sharepoint.entity import Entity
5
7
  class Principal(Entity):
6
8
  """Represents a user or group that can be assigned permissions to control security."""
7
9
 
10
+ def __str__(self):
11
+ return self.title
12
+
13
+ def __repr__(self):
14
+ return self.user_principal_name or self.id or self.entity_type_name
15
+
8
16
  @property
9
17
  def id(self):
10
- """Gets a value that specifies the member identifier for the user or group.
11
- :rtype: int or None
12
- """
18
+ # type: () -> Optional[int]
19
+ """Gets a value that specifies the member identifier for the user or group."""
13
20
  return self.properties.get("Id", None)
14
21
 
15
22
  @property
16
23
  def title(self):
17
- """Gets a value that specifies the name of the principal.
18
- :rtype: str or None
19
- """
24
+ # type: () -> Optional[str]
25
+ """Gets a value that specifies the name of the principal."""
20
26
  return self.properties.get("Title", None)
21
27
 
22
28
  @title.setter
23
29
  def title(self, value):
30
+ # type: (str) -> None
24
31
  """
25
32
  Sets a value that specifies the name of the principal.
26
- :type value: str
27
33
  """
28
34
  self.set_property("Title", value)
29
35
 
30
36
  @property
31
37
  def login_name(self):
32
- """Gets the login name of the principal.
33
- :rtype: str or None
34
- """
38
+ # type: () -> Optional[str]
39
+ """Gets the login name of the principal."""
35
40
  return self.properties.get("LoginName", None)
36
41
 
37
42
  @property
38
43
  def user_principal_name(self):
39
- """Gets the UPN of the principal.
40
- :rtype: str or None
41
- """
44
+ # type: () -> Optional[str]
45
+ """Gets the UPN of the principal."""
42
46
  return self.properties.get("UserPrincipalName", None)
43
47
 
44
48
  @property
45
49
  def is_hidden_in_ui(self):
46
- """Gets the login name of the principal.
47
- :rtype: bool or None
48
- """
50
+ # type: () -> Optional[bool]
51
+ """Gets the login name of the principal."""
49
52
  return self.properties.get("IsHiddenInUI", None)
50
53
 
51
54
  @property
52
55
  def principal_type(self):
53
- """Gets the type of the principal.
54
- :rtype: int or None
55
- """
56
+ # type: () -> Optional[int]
57
+ """Gets the type of the principal."""
56
58
  return self.properties.get("PrincipalType", None)
57
59
 
58
60
  def set_property(self, name, value, persist_changes=True):
@@ -36,6 +36,11 @@ class UserCollection(EntityCollection[User]):
36
36
  _create_and_add_query(user)
37
37
  return return_type
38
38
 
39
+ def get_by_principal_name(self, value):
40
+ # type: (str) -> User
41
+ """Returns the user with the specified principal name."""
42
+ return self.single("UserPrincipalName eq '{0}'".format(value))
43
+
39
44
  def get_by_email(self, email):
40
45
  """
41
46
  Returns the user with the specified e-mail address.