Office365-REST-Python-Client 2.5.12__py3-none-any.whl → 2.5.14__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 (201) hide show
  1. {Office365_REST_Python_Client-2.5.12.dist-info → Office365_REST_Python_Client-2.5.14.dist-info}/METADATA +1 -1
  2. {Office365_REST_Python_Client-2.5.12.dist-info → Office365_REST_Python_Client-2.5.14.dist-info}/RECORD +199 -107
  3. office365/backuprestore/root.py +39 -0
  4. office365/backuprestore/service_status.py +5 -0
  5. office365/booking/business/business.py +13 -0
  6. office365/booking/business/collection.py +8 -4
  7. office365/booking/solutions/root.py +14 -1
  8. office365/communications/callrecords/collection.py +42 -0
  9. office365/communications/callrecords/direct_routing_log_row.py +5 -0
  10. office365/communications/cloud_communications.py +2 -3
  11. office365/directory/applications/application.py +33 -2
  12. office365/directory/applications/optional_claim.py +5 -0
  13. office365/directory/applications/optional_claims.py +16 -0
  14. office365/directory/applications/required_resource_access.py +23 -0
  15. office365/directory/applications/resource_access.py +26 -0
  16. office365/directory/authentication/conditions/event_listener.py +9 -0
  17. office365/directory/authentication/methods/details.py +29 -0
  18. office365/directory/authentication/methods/root.py +8 -0
  19. office365/directory/device_local_credential_info.py +21 -0
  20. office365/directory/identities/container.py +18 -0
  21. office365/directory/permissions/scope.py +15 -3
  22. office365/directory/policies/authentication_flows.py +8 -0
  23. office365/directory/policies/authentication_strength.py +21 -0
  24. office365/directory/policies/root.py +17 -0
  25. office365/directory/policies/unified_role_management.py +7 -0
  26. office365/directory/policies/update_allowed_combinations_result.py +5 -0
  27. office365/directory/protection/policy/__init__.py +0 -0
  28. office365/directory/protection/policy/base.py +24 -0
  29. office365/directory/protection/policy/one_drive_for_business.py +10 -0
  30. office365/directory/security/alerts/evidence.py +2 -1
  31. office365/directory/security/alerts/malware_evidence.py +5 -0
  32. office365/directory/security/alerts/process_evidence.py +5 -0
  33. office365/directory/security/attacksimulations/user.py +5 -0
  34. office365/directory/security/attacksimulations/user_coverage.py +3 -0
  35. office365/directory/security/attacksimulations/users/details.py +12 -0
  36. office365/directory/serviceprincipals/service_principal.py +118 -18
  37. office365/directory/users/user.py +23 -3
  38. office365/graph_client.py +3 -1
  39. office365/intune/devices/management/management.py +26 -0
  40. office365/intune/devices/management/terms_and_conditions.py +10 -0
  41. office365/intune/devices/management/virtual_endpoint.py +8 -0
  42. office365/onedrive/driveitems/driveItem.py +1 -1
  43. office365/onedrive/driveitems/retention_label.py +33 -0
  44. office365/onedrive/driveitems/retention_label_settings.py +7 -0
  45. office365/onedrive/sitepages/base.py +3 -0
  46. office365/onedrive/sitepages/collection.py +12 -0
  47. office365/onedrive/sitepages/site_page.py +9 -9
  48. office365/onedrive/sites/archival_details.py +5 -0
  49. office365/onedrive/sites/site_collection.py +10 -1
  50. office365/onedrive/workbooks/functions/functions.py +23 -0
  51. office365/partners/__init__.py +0 -0
  52. office365/partners/billing/__init__.py +0 -0
  53. office365/planner/tasks/check_list_item.py +5 -1
  54. office365/runtime/client_object.py +24 -8
  55. office365/runtime/client_object_collection.py +4 -4
  56. office365/runtime/client_result.py +21 -2
  57. office365/runtime/client_value.py +1 -1
  58. office365/runtime/csom/request.py +11 -0
  59. office365/runtime/odata/v4/batch_request.py +12 -15
  60. office365/runtime/types/exceptions.py +18 -0
  61. office365/search/acronym.py +10 -0
  62. office365/search/aggregation_option.py +6 -0
  63. office365/search/answer.py +9 -0
  64. office365/search/entity.py +67 -14
  65. office365/search/entity_type.py +28 -0
  66. office365/search/request.py +32 -3
  67. office365/sharepoint/apps/access_requests.py +5 -0
  68. office365/sharepoint/apps/context_site.py +41 -0
  69. office365/sharepoint/apps/management/__init__.py +0 -0
  70. office365/sharepoint/apps/management/principal_info.py +9 -0
  71. office365/sharepoint/authpolicy/events/collection.py +39 -0
  72. office365/sharepoint/authpolicy/events/{auth_event.py → event.py} +1 -0
  73. office365/sharepoint/authpolicy/events/role_assignment_resource_payload.py +9 -0
  74. office365/sharepoint/brandcenter/__init__.py +0 -0
  75. office365/sharepoint/brandcenter/brand_center.py +9 -0
  76. office365/sharepoint/brandcenter/configuration.py +5 -0
  77. office365/sharepoint/changes/change.py +1 -3
  78. office365/sharepoint/changes/collection.py +3 -0
  79. office365/sharepoint/changes/folder.py +6 -0
  80. office365/sharepoint/changes/group.py +3 -0
  81. office365/sharepoint/changes/list.py +13 -0
  82. office365/sharepoint/changes/view.py +25 -0
  83. office365/sharepoint/client_context.py +19 -1
  84. office365/sharepoint/contenttypes/fieldlinks/collection.py +3 -0
  85. office365/sharepoint/copilot/__init__.py +0 -0
  86. office365/sharepoint/copilot/file_collection.py +27 -0
  87. office365/sharepoint/copilot/file_collection_query_result.py +10 -0
  88. office365/sharepoint/copilot/list_item_extensions.py +5 -0
  89. office365/sharepoint/directory/provider/alternate_id_data.py +5 -0
  90. office365/sharepoint/directory/provider/notification.py +8 -0
  91. office365/sharepoint/directory/provider/object_changes.py +5 -0
  92. office365/sharepoint/directory/provider/object_data.py +26 -3
  93. office365/sharepoint/directory/provider/provider.py +1 -0
  94. office365/sharepoint/directory/provider/session_data.py +9 -0
  95. office365/sharepoint/documentmanagement/document_id.py +28 -3
  96. office365/sharepoint/files/file.py +11 -4
  97. office365/sharepoint/files/versions/event.py +9 -0
  98. office365/sharepoint/flows/permissions.py +30 -0
  99. office365/sharepoint/listhome/favorite_item.py +9 -0
  100. office365/sharepoint/listitems/listitem.py +79 -4
  101. office365/sharepoint/listitems/update_parameters.py +4 -1
  102. office365/sharepoint/lists/data_parameters.py +5 -0
  103. office365/sharepoint/lists/exporter.py +73 -0
  104. office365/sharepoint/lists/list.py +157 -7
  105. office365/sharepoint/lists/render_data_parameters.py +31 -0
  106. office365/sharepoint/lists/version_policy_manager.py +5 -0
  107. office365/sharepoint/logger/log_export.py +2 -0
  108. office365/sharepoint/migration/copy_migration_options.py +5 -0
  109. office365/sharepoint/migrationcenter/service/performance/data.py +5 -5
  110. office365/sharepoint/multigeo/services.py +24 -0
  111. office365/sharepoint/navigation/menu_node.py +43 -1
  112. office365/sharepoint/navigation/node_collection.py +1 -1
  113. office365/sharepoint/oauth/token.py +22 -0
  114. office365/sharepoint/oauth/token_response.py +5 -0
  115. office365/sharepoint/portal/groups/site_manager.py +32 -0
  116. office365/sharepoint/portal/project/__init__.py +9 -0
  117. office365/sharepoint/portal/userprofiles/documentsshared/__init__.py +0 -0
  118. office365/sharepoint/portal/userprofiles/documentsshared/with_group.py +38 -0
  119. office365/sharepoint/portal/userprofiles/documentsshared/with_person.py +9 -0
  120. office365/sharepoint/portal/userprofiles/sharedwithme/__init__.py +0 -0
  121. office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/document.py +1 -1
  122. office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/items.py +3 -1
  123. office365/sharepoint/publishing/pages/campaign_publication.py +10 -0
  124. office365/sharepoint/publishing/pages/coauth_state.py +8 -0
  125. office365/sharepoint/publishing/pages/page.py +11 -0
  126. office365/sharepoint/publishing/pages/stream_content.py +9 -0
  127. office365/sharepoint/publishing/pages/stream_data.py +8 -0
  128. office365/sharepoint/quotamanagement/consumer/non_quota_backfill_api.py +8 -0
  129. office365/sharepoint/request.py +3 -0
  130. office365/sharepoint/search/administration/site_content_processing_info_provider.py +11 -0
  131. office365/sharepoint/search/ranking_labeling.py +1 -0
  132. office365/sharepoint/search/reports/abandonedqueries/__init__.py +0 -0
  133. office365/sharepoint/search/reports/abandonedqueries/data.py +0 -0
  134. office365/sharepoint/search/reports/abandonedqueries/item.py +5 -0
  135. office365/sharepoint/search/reports/noresult/__init__.py +0 -0
  136. office365/sharepoint/search/reports/numberofqueries/__init__.py +0 -0
  137. office365/sharepoint/search/reports/top_queries.py +7 -0
  138. office365/sharepoint/search/reports/topqueries/__init__.py +0 -0
  139. office365/sharepoint/search/reports/topqueries/data.py +9 -0
  140. office365/sharepoint/search/reports/topqueries/item.py +15 -0
  141. office365/sharepoint/search/scs_endpoint.py +9 -0
  142. office365/sharepoint/securestore/target_application.py +10 -0
  143. office365/sharepoint/sharing/document_manager.py +3 -3
  144. office365/sharepoint/sharing/inherited_from.py +5 -0
  145. office365/sharepoint/sharing/internal/__init__.py +0 -0
  146. office365/sharepoint/sharing/internal/sharing_restrictions.py +22 -0
  147. office365/sharepoint/sharing/internal/types.py +17 -0
  148. office365/sharepoint/sharing/link_info.py +24 -0
  149. office365/sharepoint/sharing/result.py +21 -0
  150. office365/sharepoint/sites/html_field_security_setting.py +5 -0
  151. office365/sharepoint/sites/site.py +39 -1
  152. office365/sharepoint/sites/version_policy_manager.py +33 -0
  153. office365/sharepoint/sitescripts/metadata.py +28 -3
  154. office365/sharepoint/sitescripts/utility.py +17 -0
  155. office365/sharepoint/smartcache/__init__.py +0 -0
  156. office365/sharepoint/smartcache/item.py +9 -0
  157. office365/sharepoint/tenant/administration/app_billing_properties.py +21 -0
  158. office365/sharepoint/tenant/administration/insights/summary_response.py +8 -0
  159. office365/sharepoint/tenant/administration/internal/aad/__init__.py +0 -0
  160. office365/sharepoint/tenant/administration/internal/aad/permission_grant.py +32 -0
  161. office365/sharepoint/tenant/administration/internal/appservice/__init__.py +0 -0
  162. office365/sharepoint/tenant/administration/internal/appservice/permission_grant.py +5 -0
  163. office365/sharepoint/tenant/administration/internal/{permission_grant.py → appservice/permission_request.py} +4 -2
  164. office365/sharepoint/tenant/administration/internal/appservice/principal.py +104 -0
  165. office365/sharepoint/tenant/administration/policies/__init__.py +0 -0
  166. office365/sharepoint/tenant/administration/policies/definition.py +5 -0
  167. office365/sharepoint/tenant/administration/settings_service.py +12 -1
  168. office365/sharepoint/tenant/administration/sites/creation_source.py +8 -8
  169. office365/sharepoint/tenant/administration/sites/properties.py +45 -0
  170. office365/sharepoint/tenant/administration/tenant.py +124 -4
  171. office365/sharepoint/tenant/administration/types.py +29 -1
  172. office365/sharepoint/tenant/cdn_api.py +3 -1
  173. office365/sharepoint/tenant/management/office365_tenant.py +2 -0
  174. office365/sharepoint/tenant/settings.py +10 -0
  175. office365/sharepoint/utilities/utility.py +6 -0
  176. office365/sharepoint/utilities/wopi_host.py +45 -0
  177. office365/sharepoint/viva/connections_page.py +8 -0
  178. office365/sharepoint/viva/dashboard_configuration.py +8 -0
  179. office365/sharepoint/viva/employee_engagement.py +39 -1
  180. office365/sharepoint/viva/resource_get_endpoint.py +8 -0
  181. office365/sharepoint/viva/resource_link.py +8 -0
  182. office365/sharepoint/webs/information.py +66 -1
  183. office365/sharepoint/webs/regional_settings.py +38 -0
  184. office365/sharepoint/webs/templates/__init__.py +0 -0
  185. office365/sharepoint/webs/time_zone.py +1 -1
  186. office365/sharepoint/webs/web.py +114 -0
  187. office365/sharepoint/workflow/definition.py +5 -0
  188. office365/sharepoint/workflow/task.py +5 -0
  189. office365/sharepoint/workflowservices/deployment_service.py +23 -0
  190. office365/subscriptions/collection.py +16 -0
  191. office365/teams/members/settings.py +2 -2
  192. office365/sharepoint/portal/userprofiles/documents_shared_with_group.py +0 -11
  193. office365/sharepoint/tenant/administration/internal/web_appservice_principal.py +0 -23
  194. {Office365_REST_Python_Client-2.5.12.dist-info → Office365_REST_Python_Client-2.5.14.dist-info}/LICENSE +0 -0
  195. {Office365_REST_Python_Client-2.5.12.dist-info → Office365_REST_Python_Client-2.5.14.dist-info}/WHEEL +0 -0
  196. {Office365_REST_Python_Client-2.5.12.dist-info → Office365_REST_Python_Client-2.5.14.dist-info}/top_level.txt +0 -0
  197. /office365/{sharepoint/userprofiles/sharedwithme → backuprestore}/__init__.py +0 -0
  198. /office365/sharepoint/portal/userprofiles/{documents_shared_with_me.py → documentsshared/with_me.py} +0 -0
  199. /office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/document_user.py +0 -0
  200. /office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/item_collection.py +0 -0
  201. /office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/view_item_removal_result.py +0 -0
@@ -6,6 +6,7 @@ from typing import TYPE_CHECKING, Any, Callable, Generic, List, Optional, TypeVa
6
6
  from requests import Response
7
7
  from typing_extensions import Self
8
8
 
9
+ from office365.runtime.client_request_exception import ClientRequestException
9
10
  from office365.runtime.client_runtime_context import ClientRuntimeContext
10
11
  from office365.runtime.client_value import ClientValue
11
12
  from office365.runtime.http.request_options import RequestOptions
@@ -29,7 +30,7 @@ class ClientObject(Generic[T]):
29
30
  # type: (ClientRuntimeContext, Optional[ResourcePath], Optional[ClientObjectCollection]) -> None
30
31
  """Base client object which define named properties and relationships of an entity."""
31
32
  self._properties = {}
32
- self._ser_property_names = []
33
+ self._properties_to_persist = []
33
34
  self._query_options = QueryOptions()
34
35
  self._parent_collection = parent_collection
35
36
  self._context = context
@@ -42,9 +43,9 @@ class ClientObject(Generic[T]):
42
43
  self._properties = {
43
44
  k: v
44
45
  for k, v in self._properties.items()
45
- if k not in self._ser_property_names
46
+ if k not in self._properties_to_persist
46
47
  }
47
- self._ser_property_names = []
48
+ self._properties_to_persist = []
48
49
  self._query_options = QueryOptions()
49
50
  return self
50
51
 
@@ -55,7 +56,12 @@ class ClientObject(Generic[T]):
55
56
  return self
56
57
 
57
58
  def execute_query_retry(
58
- self, max_retry=5, timeout_secs=5, success_callback=None, failure_callback=None
59
+ self,
60
+ max_retry=5,
61
+ timeout_secs=5,
62
+ success_callback=None,
63
+ failure_callback=None,
64
+ exceptions=(ClientRequestException,),
59
65
  ):
60
66
  """
61
67
  Executes the current set of data retrieval queries and method invocations and retries it if needed.
@@ -66,12 +72,14 @@ class ClientObject(Generic[T]):
66
72
  if the request executes successfully.
67
73
  :param (int, requests.exceptions.RequestException)-> None failure_callback: A callback to call if the request
68
74
  fails to execute
75
+ :param exceptions: tuple of exceptions that we retry
69
76
  """
70
77
  self.context.execute_query_retry(
71
78
  max_retry=max_retry,
72
79
  timeout_secs=timeout_secs,
73
80
  success_callback=success_callback,
74
81
  failure_callback=failure_callback,
82
+ exceptions=exceptions,
75
83
  )
76
84
  return self
77
85
 
@@ -131,8 +139,8 @@ class ClientObject(Generic[T]):
131
139
  Marks a property as a serializable
132
140
  :param str name: A property name
133
141
  """
134
- if name not in self._ser_property_names:
135
- self._ser_property_names.append(name)
142
+ if name not in self._properties_to_persist:
143
+ self._properties_to_persist.append(name)
136
144
  return self
137
145
 
138
146
  def get_property(self, name, default_value=None):
@@ -147,7 +155,7 @@ class ClientObject(Generic[T]):
147
155
  # type: (str|int, P_T, bool) -> Self
148
156
  """Sets property value"""
149
157
  if persist_changes:
150
- self._ser_property_names.append(name)
158
+ self._properties_to_persist.append(name)
151
159
 
152
160
  typed_value = self.get_property(name)
153
161
  if isinstance(typed_value, (ClientObject, ClientValue)):
@@ -234,6 +242,14 @@ class ClientObject(Generic[T]):
234
242
  def properties(self):
235
243
  return self._properties
236
244
 
245
+ @property
246
+ def persistable_properties(self):
247
+ return {
248
+ k: self.get_property(k)
249
+ for k in self._properties_to_persist
250
+ if k in self._properties
251
+ }
252
+
237
253
  @property
238
254
  def parent_collection(self):
239
255
  """Parent collection"""
@@ -246,7 +262,7 @@ class ClientObject(Generic[T]):
246
262
  ser_prop_names = [n for n in self._properties.keys()]
247
263
  include_control_info = False
248
264
  else:
249
- ser_prop_names = [n for n in self._ser_property_names]
265
+ ser_prop_names = [n for n in self._properties_to_persist]
250
266
  include_control_info = (
251
267
  self.entity_type_name is not None
252
268
  and json_format.include_control_information
@@ -8,6 +8,7 @@ from office365.runtime.http.request_options import RequestOptions
8
8
  from office365.runtime.odata.json_format import ODataJsonFormat
9
9
  from office365.runtime.paths.resource_path import ResourcePath
10
10
  from office365.runtime.types.event_handler import EventHandler
11
+ from office365.runtime.types.exceptions import NotFoundException
11
12
 
12
13
  T = TypeVar("T")
13
14
 
@@ -138,7 +139,7 @@ class ClientObjectCollection(ClientObject, Generic[T]):
138
139
  return self
139
140
 
140
141
  def paged(self, page_size=None, page_loaded=None):
141
- # type: (int, Callable[[Self], None]) -> Self
142
+ # type: (int, Callable[[Self], None] | None) -> Self
142
143
  """Retrieves via server-driven paging mode"""
143
144
  self._paged_mode = True
144
145
  if callable(page_loaded):
@@ -158,7 +159,7 @@ class ClientObjectCollection(ClientObject, Generic[T]):
158
159
  return self
159
160
 
160
161
  def get_all(self, page_size=None, page_loaded=None):
161
- # type: (int, Callable[[Self], None]) -> Self
162
+ # type: (int, Callable[[Self], None] | None) -> Self
162
163
  """Gets all the items in a collection, regardless of the size."""
163
164
 
164
165
  def _page_loaded(col):
@@ -213,8 +214,7 @@ class ClientObjectCollection(ClientObject, Generic[T]):
213
214
  def _after_loaded(col):
214
215
  # type: (ClientObjectCollection) -> None
215
216
  if len(col) == 0:
216
- message = "Not found for filter: {0}".format(expression)
217
- raise ValueError(message)
217
+ raise NotFoundException(return_type, expression)
218
218
  elif len(col) > 1:
219
219
  message = "Ambiguous match found for filter: {0}".format(expression)
220
220
  raise ValueError(message)
@@ -3,6 +3,7 @@ from typing import TYPE_CHECKING, Callable, Generic, Optional, TypeVar
3
3
 
4
4
  from typing_extensions import Self
5
5
 
6
+ from office365.runtime.client_request_exception import ClientRequestException
6
7
  from office365.runtime.http.request_options import RequestOptions
7
8
 
8
9
  if TYPE_CHECKING:
@@ -39,6 +40,8 @@ class ClientResult(Generic[T]):
39
40
 
40
41
  if isinstance(self._value, ClientValue):
41
42
  self._value.set_property(key, value, persist_changes)
43
+ elif isinstance(self._value, dict):
44
+ self._value[key] = value
42
45
  else:
43
46
  self._value = value
44
47
  return self
@@ -54,13 +57,29 @@ class ClientResult(Generic[T]):
54
57
  return self
55
58
 
56
59
  def execute_query_retry(
57
- self, max_retry=5, timeout_secs=5, success_callback=None, failure_callback=None
60
+ self,
61
+ max_retry=5,
62
+ timeout_secs=5,
63
+ success_callback=None,
64
+ failure_callback=None,
65
+ exceptions=(ClientRequestException,),
58
66
  ):
59
- """Executes the current set of data retrieval queries and method invocations and retries it if needed."""
67
+ """
68
+ Executes the current set of data retrieval queries and method invocations and retries it if needed.
69
+
70
+ :param int max_retry: Number of times to retry the request
71
+ :param int timeout_secs: Seconds to wait before retrying the request.
72
+ :param (office365.runtime.client_object.ClientObject)-> None success_callback: A callback to call
73
+ if the request executes successfully.
74
+ :param (int, requests.exceptions.RequestException)-> None failure_callback: A callback to call if the request
75
+ fails to execute
76
+ :param exceptions: tuple of exceptions that we retry
77
+ """
60
78
  self._context.execute_query_retry(
61
79
  max_retry=max_retry,
62
80
  timeout_secs=timeout_secs,
63
81
  success_callback=success_callback,
64
82
  failure_callback=failure_callback,
83
+ exceptions=exceptions,
65
84
  )
66
85
  return self
@@ -15,7 +15,7 @@ class ClientValue(object):
15
15
  """
16
16
 
17
17
  def set_property(self, k, v, persist_changes=True):
18
- # type: (str, Any, bool) -> Self
18
+ # type: (str|int, Any, bool) -> Self
19
19
  prop_type = getattr(self, k, None)
20
20
  if isinstance(prop_type, ClientValue) and v is not None:
21
21
  if isinstance(v, list):
@@ -0,0 +1,11 @@
1
+ from office365.runtime.client_request import ClientRequest
2
+
3
+
4
+ class CsomRequest(ClientRequest):
5
+ """"""
6
+
7
+ def process_response(self, response, query):
8
+ pass
9
+
10
+ def build_request(self, query):
11
+ pass
@@ -46,11 +46,8 @@ class ODataV4BatchRequest(ODataRequest):
46
46
  yield qry, resp
47
47
 
48
48
  def _prepare_payload(self, query):
49
- """
50
- Serializes a batch request body.
51
-
52
- :type query: office365.runtime.queries.batch.BatchQuery
53
- """
49
+ # type: (BatchQuery) -> Dict
50
+ """Serializes a batch request body."""
54
51
  requests_json = []
55
52
  for qry in query.queries:
56
53
  qry_id = str(len(requests_json))
@@ -63,16 +60,16 @@ class ODataV4BatchRequest(ODataRequest):
63
60
  # type: (ClientQuery, str, Optional[List[str]]) -> Dict[str, Any]
64
61
  """ """
65
62
  request = query.build_request()
66
- allowed_props = ["id", "method", "headers", "url", "body"]
67
- request_json = dict(
68
- (k, v)
69
- for k, v in vars(request).items()
70
- if v is not None and k in allowed_props
71
- )
72
- request_json["id"] = query_id
63
+
64
+ request_json = {
65
+ "id": query_id,
66
+ "url": request.url.replace(query.context.service_root_url(), ""),
67
+ "method": request.method,
68
+ "headers": request.headers,
69
+ }
70
+ if request.data:
71
+ request_json["body"] = request.data
72
+
73
73
  if depends_on is not None:
74
74
  request_json["dependsOn"] = depends_on
75
- request_json["url"] = request_json["url"].replace(
76
- query.context.service_root_url(), ""
77
- )
78
75
  return request_json
@@ -0,0 +1,18 @@
1
+ from office365.runtime.client_object import ClientObject
2
+
3
+
4
+ class NotFoundException(Exception):
5
+ def __init__(self, entity=None, query=None):
6
+ # type: (ClientObject, str) -> None
7
+ self.entity = entity
8
+ self.query = query
9
+
10
+ def __str__(self):
11
+ if self.entity is None:
12
+ message = "Entity not found"
13
+ else:
14
+ message = "{0} not found".format(self.entity.entity_type_name)
15
+
16
+ if self.query is not None:
17
+ message = "{0} for query: {1}".format(message, self.query)
18
+ return message
@@ -0,0 +1,10 @@
1
+ from office365.search.answer import SearchAnswer
2
+
3
+
4
+ class Acronym(SearchAnswer):
5
+ """Represents an acronym that is an administrative answer in Microsoft Search results to define common
6
+ acronyms in an organization."""
7
+
8
+ @property
9
+ def entity_type_name(self):
10
+ return "microsoft.graph.search.acronym"
@@ -0,0 +1,6 @@
1
+ from office365.runtime.client_value import ClientValue
2
+
3
+
4
+ class AggregationOption(ClientValue):
5
+ """Specifies which aggregations should be returned alongside the search results.
6
+ The maximum returned value is 100 buckets."""
@@ -0,0 +1,9 @@
1
+ from office365.entity import Entity
2
+
3
+
4
+ class SearchAnswer(Entity):
5
+ """Represents the base type for other search answers."""
6
+
7
+ @property
8
+ def entity_type_name(self):
9
+ return "microsoft.graph.search.searchAnswer"
@@ -1,10 +1,15 @@
1
1
  from typing import List, Optional
2
2
 
3
3
  from office365.entity import Entity
4
+ from office365.entity_collection import EntityCollection
4
5
  from office365.runtime.client_result import ClientResult
5
6
  from office365.runtime.client_value_collection import ClientValueCollection
7
+ from office365.runtime.paths.resource_path import ResourcePath
8
+ from office365.runtime.paths.v4.entity import EntityPath
6
9
  from office365.runtime.queries.service_operation import ServiceOperationQuery
10
+ from office365.search.acronym import Acronym
7
11
  from office365.search.entity_type import EntityType
12
+ from office365.search.hit import SearchHit
8
13
  from office365.search.query import SearchQuery
9
14
  from office365.search.request import SearchRequest
10
15
  from office365.search.response import SearchResponse
@@ -16,27 +21,42 @@ class SearchEntity(Entity):
16
21
  in Graph, but serves as an anchor to the query action.
17
22
  """
18
23
 
19
- def query(self, query_string, entity_types=None):
20
- # type: (str, Optional[List[str]]) -> ClientResult[ClientValueCollection[SearchResponse]]
24
+ def query(
25
+ self,
26
+ query_string,
27
+ entity_types=None,
28
+ page_from=None,
29
+ size=None,
30
+ enable_top_results=None,
31
+ ):
32
+ # type: (str, Optional[List[str]], Optional[int], Optional[int], Optional[bool]) -> ClientResult[ClientValueCollection[SearchResponse]]
21
33
  """
22
34
  Runs the query specified in the request body. Search results are provided in the response.
23
35
 
24
36
  :param str query_string: Contains the query terms.
25
37
  :param list[str] entity_types: One or more types of resources expected in the response.
26
38
  Possible values are: list, site, listItem, message, event, drive, driveItem, externalItem.
39
+ :param int page_from: Specifies the offset for the search results. Offset 0 returns the very first result.
40
+ :param int size: The size of the page to be retrieved. The maximum value is 500. Optional.
41
+ :param bool enable_top_results: This triggers hybrid sort for messages
27
42
  """
28
43
  search_request = SearchRequest(
29
- query=SearchQuery(query_string), entity_types=entity_types
44
+ query=SearchQuery(query_string),
45
+ entity_types=entity_types,
46
+ page_from=page_from,
47
+ size=size,
48
+ enable_top_results=enable_top_results,
30
49
  )
31
- payload = {"requests": ClientValueCollection(SearchRequest, [search_request])}
32
- return_type = ClientResult(self.context, ClientValueCollection(SearchResponse))
33
- qry = ServiceOperationQuery(self, "query", None, payload, None, return_type)
34
50
 
35
51
  def _patch_hit(search_hit):
36
- pass
37
- # resource = Entity(self.context)
38
- # self.context.pending_request().map_json(search_hit.resource, resource)
39
- # search_hit.set_property("resource", resource)
52
+ # type: (SearchHit) -> None
53
+ resource_type_name = search_hit.get_property("resource").get(
54
+ "@odata.type", None
55
+ )
56
+ resource_type = EntityType.resolve(resource_type_name)
57
+ resource = resource_type(self.context, EntityPath())
58
+ self.context.pending_request().map_json(search_hit.resource, resource)
59
+ search_hit.set_property("resource", resource)
40
60
 
41
61
  def _process_response(result):
42
62
  # type: (ClientResult[ClientValueCollection[SearchResponse]]) -> None
@@ -44,14 +64,28 @@ class SearchEntity(Entity):
44
64
  for hcs in item.hitsContainers:
45
65
  [_patch_hit(hit) for hit in hcs.hits]
46
66
 
67
+ payload = {"requests": ClientValueCollection(SearchRequest, [search_request])}
68
+ return_type = ClientResult(self.context, ClientValueCollection(SearchResponse))
69
+ qry = ServiceOperationQuery(self, "query", None, payload, None, return_type)
47
70
  self.context.add_query(qry).after_query_execute(_process_response)
48
71
  return return_type
49
72
 
50
- def query_messages(self, query_string):
73
+ def query_messages(
74
+ self, query_string, page_from=None, size=None, enable_top_results=None
75
+ ):
51
76
  """Searches Outlook messages. Alias to query method
52
77
  :param str query_string: Contains the query terms.
78
+ :param int page_from: Specifies the offset for the search results. Offset 0 returns the very first result.
79
+ :param int size: The size of the page to be retrieved. The maximum value is 500. Optional.
80
+ :param bool enable_top_results: This triggers hybrid sort for messages
53
81
  """
54
- return self.query(query_string, entity_types=[EntityType.message])
82
+ return self.query(
83
+ query_string,
84
+ entity_types=[EntityType.message],
85
+ page_from=page_from,
86
+ size=size,
87
+ enable_top_results=enable_top_results,
88
+ )
55
89
 
56
90
  def query_events(self, query_string):
57
91
  """Searches Outlook calendar events. Alias to query method
@@ -59,8 +93,27 @@ class SearchEntity(Entity):
59
93
  """
60
94
  return self.query(query_string, entity_types=[EntityType.event])
61
95
 
62
- def query_drive_items(self, query_string):
96
+ def query_drive_items(self, query_string, page_from=None, size=None):
63
97
  """Searches OneDrive items. Alias to query method
64
98
  :param str query_string: Contains the query terms.
99
+ :param int page_from: Specifies the offset for the search results. Offset 0 returns the very first result.
100
+ :param int size: The size of the page to be retrieved. The maximum value is 500.
65
101
  """
66
- return self.query(query_string, entity_types=[EntityType.driveItem])
102
+ return self.query(
103
+ query_string,
104
+ entity_types=[EntityType.driveItem],
105
+ page_from=page_from,
106
+ size=size,
107
+ )
108
+
109
+ @property
110
+ def acronyms(self):
111
+ """Administrative answer in Microsoft Search results to define common acronyms in an organization."""
112
+ return self.properties.get(
113
+ "acronyms",
114
+ EntityCollection(
115
+ self.context,
116
+ Acronym,
117
+ ResourcePath("acronyms", self.resource_path),
118
+ ),
119
+ )
@@ -1,9 +1,37 @@
1
+ from typing import Type
2
+
3
+ from office365.onedrive.driveitems.driveItem import DriveItem
4
+ from office365.onedrive.drives.drive import Drive
5
+ from office365.onedrive.listitems.list_item import ListItem
6
+ from office365.onedrive.lists.list import List
7
+ from office365.onedrive.sites.site import Site
8
+ from office365.outlook.calendar.events.event import Event
9
+ from office365.outlook.mail.messages.message import Message
10
+
11
+
1
12
  class EntityType:
2
13
  """Search resource type"""
3
14
 
15
+ _types = {
16
+ "event": Event,
17
+ "list": List,
18
+ "site": Site,
19
+ "listItem": ListItem,
20
+ "message": Message,
21
+ "drive": Drive,
22
+ "driveItem": DriveItem,
23
+ # "externalItem": ExternalItem
24
+ }
25
+
4
26
  def __init__(self):
5
27
  pass
6
28
 
29
+ @staticmethod
30
+ def resolve(name):
31
+ # type: (str) -> Type[Event | List | Site | ListItem | Message | Drive | DriveItem]
32
+ class_name = name.split(".")[-1]
33
+ return EntityType._types.get(class_name, None)
34
+
7
35
  event = "event"
8
36
 
9
37
  list = "list"
@@ -1,6 +1,10 @@
1
+ from typing import Dict, Optional
2
+
1
3
  from office365.runtime.client_value import ClientValue
2
4
  from office365.runtime.client_value_collection import ClientValueCollection
5
+ from office365.runtime.odata.json_format import ODataJsonFormat
3
6
  from office365.runtime.types.collections import StringCollection
7
+ from office365.search.aggregation_option import AggregationOption
4
8
  from office365.search.sharepoint_onedrive_options import SharePointOneDriveOptions
5
9
  from office365.search.sort_property import SortProperty
6
10
 
@@ -11,15 +15,29 @@ class SearchRequest(ClientValue):
11
15
  def __init__(
12
16
  self,
13
17
  query,
18
+ aggregation_filters=None,
19
+ aggregations=None,
20
+ enable_top_results=None,
21
+ size=None,
22
+ region=None,
14
23
  entity_types=None,
15
24
  fields=None,
16
- search_from=None,
25
+ page_from=None,
17
26
  sort_properties=None,
18
27
  content_sources=None,
19
28
  sharepoint_onedrive_options=SharePointOneDriveOptions(),
20
29
  ):
21
30
  """
22
31
  :param office365.search.query.SearchQuery query: Contains the query terms.
32
+ :param list[str] aggregation_filters: Contains one or more filters to obtain search results aggregated and
33
+ filtered to a specific value of a field
34
+ :param list[str] aggregations: Specifies aggregations (also known as refiners) to be returned
35
+ alongside search results.
36
+ :param bool enable_top_results: This triggers hybrid sort for messages : the first 3 messages are
37
+ the most relevant. This property is only applicable to entityType=message. Optional.
38
+ :param int size: The size of the page to be retrieved. The maximum value is 500. Optional.
39
+ :param str region: The geographic location for the search. Required for searches that use application
40
+ permissions. For details, see Get the region value.
23
41
  :param list[str] entity_types: One or more types of resources expected in the response.
24
42
  Possible values are: list, site, listItem, message, event, drive, driveItem, externalItem.
25
43
  See known limitations for those combinations of two or more entity types that are supported in the
@@ -30,16 +48,27 @@ class SearchRequest(ClientValue):
30
48
  content that Microsoft Graph connectors bring in. The fields property can use the semantic labels
31
49
  applied to properties. For example, if a property is labeled as title, you can retrieve it using
32
50
  the following syntax: label_title.
33
- :param int search_from: Specifies the offset for the search results. Offset 0 returns the very first result.
51
+ :param int page_from: Specifies the offset for the search results. Offset 0 returns the very first result.
34
52
  :param list[SortProperty] sort_properties: Contains the ordered collection of fields and direction to
35
53
  sort results. There can be at most 5 sort properties in the collection.
36
54
  :param list[str] content_sources: Contains the connection to be targeted.
37
55
  """
38
56
  super(SearchRequest, self).__init__()
39
57
  self.query = query
58
+ self.aggregationFilters = StringCollection(aggregation_filters)
59
+ self.aggregations = ClientValueCollection(AggregationOption, aggregations)
60
+ self.enableTopResults = enable_top_results
61
+ self.size = size
62
+ self.region = region
40
63
  self.entityTypes = entity_types
41
64
  self.fields = fields
42
- self.search_from = search_from
65
+ self.page_from = page_from
43
66
  self.sortProperties = ClientValueCollection(SortProperty, sort_properties)
44
67
  self.contentSources = StringCollection(content_sources)
45
68
  self.sharePointOneDriveOptions = sharepoint_onedrive_options
69
+
70
+ def to_json(self, json_format=None):
71
+ # type: (Optional[ODataJsonFormat]) -> Dict
72
+ json_value = super(SearchRequest, self).to_json(json_format)
73
+ json_value["from"] = json_value.pop("page_from", None)
74
+ return json_value
@@ -0,0 +1,5 @@
1
+ from office365.sharepoint.entity import Entity
2
+
3
+
4
+ class AccessRequests(Entity):
5
+ """ """
@@ -0,0 +1,41 @@
1
+ from office365.onedrive.sites.site import Site
2
+ from office365.runtime.paths.resource_path import ResourcePath
3
+ from office365.runtime.paths.service_operation import ServiceOperationPath
4
+ from office365.sharepoint.client_context import ClientContext
5
+ from office365.sharepoint.entity import Entity
6
+ from office365.sharepoint.webs.web import Web
7
+
8
+
9
+ class AppContextSite(Entity):
10
+ """ """
11
+
12
+ def __init__(self, context, site_url):
13
+ # type: (ClientContext, str) -> None
14
+ """"""
15
+ static_path = ServiceOperationPath(
16
+ "SP.AppContextSite",
17
+ {"siteUrl": site_url},
18
+ )
19
+ super(AppContextSite, self).__init__(context, static_path)
20
+
21
+ @property
22
+ def site(self):
23
+ """"""
24
+ return self.properties.get(
25
+ "Site",
26
+ Site(
27
+ self.context,
28
+ ResourcePath("Site", self.resource_path),
29
+ ),
30
+ )
31
+
32
+ @property
33
+ def web(self):
34
+ """"""
35
+ return self.properties.get(
36
+ "Web",
37
+ Web(
38
+ self.context,
39
+ ResourcePath("Web", self.resource_path),
40
+ ),
41
+ )
File without changes
@@ -0,0 +1,9 @@
1
+ from office365.sharepoint.entity import Entity
2
+
3
+
4
+ class SPAppPrincipalInfo(Entity):
5
+ """"""
6
+
7
+ @property
8
+ def entity_type_name(self):
9
+ return "Microsoft.SharePoint.AppManagement.SPAppPrincipalInfo"
@@ -0,0 +1,39 @@
1
+ from office365.runtime.queries.service_operation import ServiceOperationQuery
2
+ from office365.sharepoint.authpolicy.events.event import SPAuthEvent
3
+ from office365.sharepoint.entity_collection import EntityCollection
4
+
5
+
6
+ class SPAuthEventCollection(EntityCollection[SPAuthEvent]):
7
+ """Represents a collection of Field resource."""
8
+
9
+ def __init__(self, context, resource_path=None, parent=None):
10
+ super(SPAuthEventCollection, self).__init__(
11
+ context, SPAuthEvent, resource_path, parent
12
+ )
13
+
14
+ def role_assignment_ms_graph_notify(
15
+ self, tenant, action, type_, resource_payload, id_, container_id
16
+ ):
17
+ """
18
+ :param str tenant:
19
+ :param str action:
20
+ :param str type_:
21
+ :param RoleAssignmentResourcePayload resource_payload:
22
+ :param str id_:
23
+ :param str container_id:
24
+ """
25
+ payload = {
26
+ "tenant": tenant,
27
+ "action": action,
28
+ "type": type_,
29
+ "resourcePayload": resource_payload,
30
+ "id": id_,
31
+ "containerId": container_id,
32
+ }
33
+ return_type = SPAuthEvent(self.context)
34
+ self.add_child(return_type)
35
+ qry = ServiceOperationQuery(
36
+ self, "RoleAssignmentMSGraphNotify", None, payload, None, return_type
37
+ )
38
+ self.context.add_query(qry)
39
+ return return_type
@@ -2,6 +2,7 @@ from office365.sharepoint.entity import Entity
2
2
 
3
3
 
4
4
  class SPAuthEvent(Entity):
5
+
5
6
  @property
6
7
  def entity_type_name(self):
7
8
  return "Microsoft.SharePoint.AuthPolicy.Events.SPAuthEvent"
@@ -0,0 +1,9 @@
1
+ from office365.runtime.client_value import ClientValue
2
+
3
+
4
+ class RoleAssignmentResourcePayload(ClientValue):
5
+ """ """
6
+
7
+ @property
8
+ def entity_type_name(self):
9
+ return "Microsoft.SharePoint.AuthPolicy.Events.RoleAssignmentResourcePayload"
File without changes