Office365-REST-Python-Client 2.5.13__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.
- {Office365_REST_Python_Client-2.5.13.dist-info → Office365_REST_Python_Client-2.5.14.dist-info}/METADATA +1 -1
- {Office365_REST_Python_Client-2.5.13.dist-info → Office365_REST_Python_Client-2.5.14.dist-info}/RECORD +135 -78
- office365/booking/business/business.py +13 -0
- office365/booking/business/collection.py +8 -4
- office365/communications/callrecords/collection.py +42 -0
- office365/communications/callrecords/direct_routing_log_row.py +5 -0
- office365/communications/cloud_communications.py +2 -3
- office365/directory/applications/application.py +16 -2
- office365/directory/applications/required_resource_access.py +23 -0
- office365/directory/applications/resource_access.py +26 -0
- office365/directory/authentication/methods/details.py +29 -0
- office365/directory/authentication/methods/root.py +8 -0
- office365/directory/permissions/scope.py +15 -3
- office365/directory/policies/authentication_strength.py +21 -0
- office365/directory/policies/update_allowed_combinations_result.py +5 -0
- office365/directory/security/alerts/evidence.py +2 -1
- office365/directory/security/alerts/malware_evidence.py +5 -0
- office365/directory/security/alerts/process_evidence.py +5 -0
- office365/directory/security/attacksimulations/user.py +5 -0
- office365/directory/security/attacksimulations/user_coverage.py +3 -0
- office365/directory/security/attacksimulations/users/details.py +6 -1
- office365/directory/serviceprincipals/service_principal.py +86 -37
- office365/onedrive/driveitems/driveItem.py +1 -1
- office365/onedrive/driveitems/retention_label.py +33 -0
- office365/onedrive/driveitems/retention_label_settings.py +7 -0
- office365/onedrive/sitepages/base.py +3 -0
- office365/onedrive/sitepages/collection.py +12 -0
- office365/onedrive/sitepages/site_page.py +9 -9
- office365/onedrive/sites/archival_details.py +5 -0
- office365/onedrive/sites/site_collection.py +10 -1
- office365/onedrive/workbooks/functions/functions.py +23 -0
- office365/partners/billing/__init__.py +0 -0
- office365/planner/tasks/check_list_item.py +5 -1
- office365/runtime/client_object.py +15 -7
- office365/runtime/client_object_collection.py +2 -2
- office365/runtime/client_result.py +2 -0
- office365/runtime/client_value.py +1 -1
- office365/runtime/csom/request.py +11 -0
- office365/runtime/types/exceptions.py +18 -0
- office365/search/acronym.py +10 -0
- office365/search/aggregation_option.py +6 -0
- office365/search/answer.py +9 -0
- office365/search/entity.py +67 -14
- office365/search/entity_type.py +28 -0
- office365/search/request.py +32 -3
- office365/sharepoint/apps/access_requests.py +5 -0
- office365/sharepoint/apps/management/__init__.py +0 -0
- office365/sharepoint/apps/management/principal_info.py +9 -0
- office365/sharepoint/authpolicy/events/collection.py +28 -0
- office365/sharepoint/authpolicy/events/role_assignment_resource_payload.py +4 -0
- office365/sharepoint/documentmanagement/document_id.py +28 -3
- office365/sharepoint/files/file.py +11 -4
- office365/sharepoint/files/versions/event.py +9 -0
- office365/sharepoint/flows/permissions.py +30 -0
- office365/sharepoint/listhome/favorite_item.py +9 -0
- office365/sharepoint/listitems/listitem.py +79 -4
- office365/sharepoint/listitems/update_parameters.py +4 -1
- office365/sharepoint/lists/data_parameters.py +5 -0
- office365/sharepoint/lists/exporter.py +73 -0
- office365/sharepoint/lists/list.py +148 -61
- office365/sharepoint/lists/render_data_parameters.py +31 -0
- office365/sharepoint/lists/version_policy_manager.py +5 -0
- office365/sharepoint/migration/copy_migration_options.py +5 -0
- office365/sharepoint/portal/groups/site_manager.py +32 -0
- office365/sharepoint/portal/project/__init__.py +9 -0
- office365/sharepoint/portal/userprofiles/documentsshared/__init__.py +0 -0
- office365/sharepoint/portal/userprofiles/documentsshared/with_group.py +38 -0
- office365/sharepoint/portal/userprofiles/documentsshared/with_person.py +9 -0
- office365/sharepoint/portal/userprofiles/sharedwithme/__init__.py +0 -0
- office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/document.py +1 -1
- office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/items.py +3 -1
- office365/sharepoint/publishing/pages/coauth_state.py +8 -0
- office365/sharepoint/publishing/pages/page.py +11 -0
- office365/sharepoint/publishing/pages/stream_content.py +9 -0
- office365/sharepoint/publishing/pages/stream_data.py +8 -0
- office365/sharepoint/quotamanagement/consumer/non_quota_backfill_api.py +8 -0
- office365/sharepoint/request.py +3 -0
- office365/sharepoint/search/administration/site_content_processing_info_provider.py +11 -0
- office365/sharepoint/search/ranking_labeling.py +1 -0
- office365/sharepoint/search/reports/abandonedqueries/__init__.py +0 -0
- office365/sharepoint/search/reports/abandonedqueries/data.py +0 -0
- office365/sharepoint/search/reports/abandonedqueries/item.py +5 -0
- office365/sharepoint/search/reports/noresult/__init__.py +0 -0
- office365/sharepoint/search/reports/numberofqueries/__init__.py +0 -0
- office365/sharepoint/search/reports/top_queries.py +7 -0
- office365/sharepoint/search/reports/topqueries/__init__.py +0 -0
- office365/sharepoint/search/reports/topqueries/data.py +9 -0
- office365/sharepoint/search/reports/topqueries/item.py +15 -0
- office365/sharepoint/search/scs_endpoint.py +9 -0
- office365/sharepoint/securestore/target_application.py +8 -0
- office365/sharepoint/sharing/document_manager.py +3 -3
- office365/sharepoint/sharing/result.py +21 -0
- office365/sharepoint/sites/html_field_security_setting.py +5 -0
- office365/sharepoint/sites/site.py +30 -1
- office365/sharepoint/sites/version_policy_manager.py +25 -0
- office365/sharepoint/sitescripts/metadata.py +28 -3
- office365/sharepoint/sitescripts/utility.py +17 -0
- office365/sharepoint/smartcache/__init__.py +0 -0
- office365/sharepoint/smartcache/item.py +9 -0
- office365/sharepoint/tenant/administration/app_billing_properties.py +21 -0
- office365/sharepoint/tenant/administration/insights/summary_response.py +8 -0
- office365/sharepoint/tenant/administration/internal/aad/__init__.py +0 -0
- office365/sharepoint/tenant/administration/internal/aad/permission_grant.py +32 -0
- office365/sharepoint/tenant/administration/internal/appservice/__init__.py +0 -0
- office365/sharepoint/tenant/administration/internal/appservice/permission_grant.py +5 -0
- office365/sharepoint/tenant/administration/internal/{permission_grant.py → appservice/permission_request.py} +4 -2
- office365/sharepoint/tenant/administration/internal/appservice/principal.py +104 -0
- office365/sharepoint/tenant/administration/settings_service.py +4 -1
- office365/sharepoint/tenant/administration/sites/creation_source.py +8 -8
- office365/sharepoint/tenant/administration/tenant.py +110 -4
- office365/sharepoint/tenant/administration/types.py +13 -1
- office365/sharepoint/tenant/cdn_api.py +3 -1
- office365/sharepoint/tenant/management/office365_tenant.py +2 -0
- office365/sharepoint/tenant/settings.py +10 -0
- office365/sharepoint/utilities/utility.py +6 -0
- office365/sharepoint/viva/connections_page.py +8 -0
- office365/sharepoint/viva/dashboard_configuration.py +8 -0
- office365/sharepoint/viva/employee_engagement.py +39 -1
- office365/sharepoint/viva/resource_get_endpoint.py +8 -0
- office365/sharepoint/viva/resource_link.py +8 -0
- office365/sharepoint/webs/information.py +66 -1
- office365/sharepoint/webs/regional_settings.py +32 -0
- office365/sharepoint/webs/templates/__init__.py +0 -0
- office365/sharepoint/webs/time_zone.py +1 -1
- office365/sharepoint/webs/web.py +58 -0
- office365/sharepoint/workflow/task.py +5 -0
- office365/subscriptions/collection.py +16 -0
- office365/sharepoint/portal/userprofiles/documents_shared_with_group.py +0 -11
- office365/sharepoint/tenant/administration/internal/web_appservice_principal.py +0 -23
- {Office365_REST_Python_Client-2.5.13.dist-info → Office365_REST_Python_Client-2.5.14.dist-info}/LICENSE +0 -0
- {Office365_REST_Python_Client-2.5.13.dist-info → Office365_REST_Python_Client-2.5.14.dist-info}/WHEEL +0 -0
- {Office365_REST_Python_Client-2.5.13.dist-info → Office365_REST_Python_Client-2.5.14.dist-info}/top_level.txt +0 -0
- /office365/{sharepoint/userprofiles/sharedwithme → partners}/__init__.py +0 -0
- /office365/sharepoint/portal/userprofiles/{documents_shared_with_me.py → documentsshared/with_me.py} +0 -0
- /office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/document_user.py +0 -0
- /office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/item_collection.py +0 -0
- /office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/view_item_removal_result.py +0 -0
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
from datetime import datetime
|
|
1
2
|
from typing import Optional
|
|
2
3
|
|
|
3
4
|
from office365.directory.permissions.identity_set import IdentitySet
|
|
4
5
|
from office365.entity import Entity
|
|
6
|
+
from office365.onedrive.driveitems.retention_label_settings import (
|
|
7
|
+
RetentionLabelSettings,
|
|
8
|
+
)
|
|
5
9
|
|
|
6
10
|
|
|
7
11
|
class ItemRetentionLabel(Entity):
|
|
@@ -23,3 +27,32 @@ class ItemRetentionLabel(Entity):
|
|
|
23
27
|
# type: () -> Optional[IdentitySet]
|
|
24
28
|
"""Identity of the user who applied the label. Read-only."""
|
|
25
29
|
return self.properties.get("labelAppliedBy", IdentitySet())
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def label_applied_datetime(self):
|
|
33
|
+
# type: () -> Optional[datetime]
|
|
34
|
+
"""The date and time when the label was applied on the item.
|
|
35
|
+
The timestamp type represents date and time information using ISO 8601 format and is always in UTC.
|
|
36
|
+
"""
|
|
37
|
+
return self.properties.get("labelAppliedDateTime", datetime.min)
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def name(self):
|
|
41
|
+
# type: () -> Optional[str]
|
|
42
|
+
"""The retention label on the document. Read-write."""
|
|
43
|
+
return self.properties.get("name", None)
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def retention_settings(self):
|
|
47
|
+
# type: () -> RetentionLabelSettings
|
|
48
|
+
"""The retention settings enforced on the item. Read-write."""
|
|
49
|
+
return self.properties.get("retentionSettings", RetentionLabelSettings())
|
|
50
|
+
|
|
51
|
+
def get_property(self, name, default_value=None):
|
|
52
|
+
if default_value is None:
|
|
53
|
+
property_mapping = {
|
|
54
|
+
"labelAppliedBy": self.label_applied_by,
|
|
55
|
+
"retentionSettings": self.retention_settings,
|
|
56
|
+
}
|
|
57
|
+
default_value = property_mapping.get(name, None)
|
|
58
|
+
return super(ItemRetentionLabel, self).get_property(name, default_value)
|
|
@@ -7,6 +7,9 @@ from office365.onedrive.driveitems.publication_facet import PublicationFacet
|
|
|
7
7
|
class BaseSitePage(BaseItem):
|
|
8
8
|
"""An abstract type that represents a page in the site page library."""
|
|
9
9
|
|
|
10
|
+
def __repr__(self):
|
|
11
|
+
return self.name or self.entity_type_name
|
|
12
|
+
|
|
10
13
|
@property
|
|
11
14
|
def publishing_state(self):
|
|
12
15
|
# type: () -> Optional[str]
|
|
@@ -10,10 +10,22 @@ class SitePageCollection(EntityCollection[SitePage]):
|
|
|
10
10
|
def __init__(self, context, resource_path=None):
|
|
11
11
|
super(SitePageCollection, self).__init__(context, SitePage, resource_path)
|
|
12
12
|
|
|
13
|
+
def get(self):
|
|
14
|
+
def _construct_request(request):
|
|
15
|
+
# type: (RequestOptions) -> None
|
|
16
|
+
# request.url += "/microsoft.graph.sitePage"
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
return super(SitePageCollection, self).get().before_execute(_construct_request)
|
|
20
|
+
|
|
21
|
+
def get_by_name(self, name):
|
|
22
|
+
return self.single("name eq '{0}'".format(name))
|
|
23
|
+
|
|
13
24
|
def add(self, title):
|
|
14
25
|
"""
|
|
15
26
|
Create a new sitePage in the site pages list in a site.
|
|
16
27
|
|
|
28
|
+
:param str title:
|
|
17
29
|
"""
|
|
18
30
|
|
|
19
31
|
def _construct_request(request):
|
|
@@ -15,23 +15,23 @@ class SitePage(BaseSitePage):
|
|
|
15
15
|
webParts."""
|
|
16
16
|
|
|
17
17
|
def get_web_parts_by_position(
|
|
18
|
-
self,
|
|
18
|
+
self, web_part_index, horizontal_section_id, is_in_vertical_section, column_id
|
|
19
19
|
):
|
|
20
20
|
"""
|
|
21
21
|
Get a collection of webPart by providing webPartPosition information.
|
|
22
22
|
|
|
23
|
-
:param float
|
|
23
|
+
:param float web_part_index: Index of the current WebPart. Represents the order of WebPart in this column or
|
|
24
24
|
section. Only works if either columnId or isInVerticalSection is provided.
|
|
25
|
-
:param float
|
|
26
|
-
:param bool
|
|
27
|
-
:param float
|
|
25
|
+
:param float horizontal_section_id: Indicate the horizontal section where the WebPart located in.
|
|
26
|
+
:param bool is_in_vertical_section: Indicate whether the WebPart located in the vertical section.
|
|
27
|
+
:param float column_id: Indicate the identifier of the column where the WebPart located in. Only works
|
|
28
28
|
if horizontalSectionId is provided.
|
|
29
29
|
"""
|
|
30
30
|
params = {
|
|
31
|
-
"webPartIndex":
|
|
32
|
-
"horizontalSectionId":
|
|
33
|
-
"isInverticalSection":
|
|
34
|
-
"columnId":
|
|
31
|
+
"webPartIndex": web_part_index,
|
|
32
|
+
"horizontalSectionId": horizontal_section_id,
|
|
33
|
+
"isInverticalSection": is_in_vertical_section,
|
|
34
|
+
"columnId": column_id,
|
|
35
35
|
}
|
|
36
36
|
return_type = EntityCollection(
|
|
37
37
|
self.context, WebPart, ResourcePath("webParts", self.resource_path)
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
+
from office365.onedrive.sites.archival_details import SiteArchivalDetails
|
|
1
2
|
from office365.runtime.client_value import ClientValue
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class SiteCollection(ClientValue):
|
|
5
6
|
"""The siteCollection resource provides more information about a site collection."""
|
|
6
7
|
|
|
7
|
-
def __init__(
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
root=None,
|
|
11
|
+
hostname=None,
|
|
12
|
+
data_location_code=None,
|
|
13
|
+
archival_details=SiteArchivalDetails(),
|
|
14
|
+
):
|
|
8
15
|
"""
|
|
9
16
|
|
|
10
17
|
:param office365.onedrive.root.Root root: The hostname for the site collection.
|
|
11
18
|
:param str hostname: The hostname for the site collection.
|
|
12
19
|
:param str data_location_code: The geographic region code for where this site collection resides
|
|
20
|
+
:param str archival_details: Represents the archival details of a siteCollection.
|
|
13
21
|
"""
|
|
14
22
|
super(SiteCollection, self).__init__()
|
|
15
23
|
self.root = root
|
|
16
24
|
self.hostname = hostname
|
|
17
25
|
self.dataLocationCode = data_location_code
|
|
26
|
+
self.archivalDetails = archival_details
|
|
@@ -45,6 +45,29 @@ class WorkbookFunctions(Entity):
|
|
|
45
45
|
self.context.add_query(qry)
|
|
46
46
|
return return_type
|
|
47
47
|
|
|
48
|
+
def accr_int_m(self, issue, settlement, rate, par, basis):
|
|
49
|
+
"""
|
|
50
|
+
Returns the accrued interest for a security that pays periodic interest.
|
|
51
|
+
|
|
52
|
+
:param any issue: The real number of which you want the absolute value.
|
|
53
|
+
:param any settlement: The security's settlement date. The security settlement date is the date after
|
|
54
|
+
the issue date when the security is traded to the buyer.
|
|
55
|
+
:param any rate: The security's annual coupon rate.
|
|
56
|
+
:param any par: The security's par value. If you omit par, ACCRINT uses $1,000.
|
|
57
|
+
:param any basis:
|
|
58
|
+
"""
|
|
59
|
+
return_type = WorkbookFunctionResult(self.context)
|
|
60
|
+
payload = {
|
|
61
|
+
"issue": issue,
|
|
62
|
+
"settlement": settlement,
|
|
63
|
+
"rate": rate,
|
|
64
|
+
"par": par,
|
|
65
|
+
"basis": basis,
|
|
66
|
+
}
|
|
67
|
+
qry = ServiceOperationQuery(self, "accrIntM", None, payload, None, return_type)
|
|
68
|
+
self.context.add_query(qry)
|
|
69
|
+
return return_type
|
|
70
|
+
|
|
48
71
|
def days(self, start_date, end_date):
|
|
49
72
|
"""Returns the number of days between two dates.
|
|
50
73
|
|
|
File without changes
|
|
@@ -30,7 +30,7 @@ class ClientObject(Generic[T]):
|
|
|
30
30
|
# type: (ClientRuntimeContext, Optional[ResourcePath], Optional[ClientObjectCollection]) -> None
|
|
31
31
|
"""Base client object which define named properties and relationships of an entity."""
|
|
32
32
|
self._properties = {}
|
|
33
|
-
self.
|
|
33
|
+
self._properties_to_persist = []
|
|
34
34
|
self._query_options = QueryOptions()
|
|
35
35
|
self._parent_collection = parent_collection
|
|
36
36
|
self._context = context
|
|
@@ -43,9 +43,9 @@ class ClientObject(Generic[T]):
|
|
|
43
43
|
self._properties = {
|
|
44
44
|
k: v
|
|
45
45
|
for k, v in self._properties.items()
|
|
46
|
-
if k not in self.
|
|
46
|
+
if k not in self._properties_to_persist
|
|
47
47
|
}
|
|
48
|
-
self.
|
|
48
|
+
self._properties_to_persist = []
|
|
49
49
|
self._query_options = QueryOptions()
|
|
50
50
|
return self
|
|
51
51
|
|
|
@@ -139,8 +139,8 @@ class ClientObject(Generic[T]):
|
|
|
139
139
|
Marks a property as a serializable
|
|
140
140
|
:param str name: A property name
|
|
141
141
|
"""
|
|
142
|
-
if name not in self.
|
|
143
|
-
self.
|
|
142
|
+
if name not in self._properties_to_persist:
|
|
143
|
+
self._properties_to_persist.append(name)
|
|
144
144
|
return self
|
|
145
145
|
|
|
146
146
|
def get_property(self, name, default_value=None):
|
|
@@ -155,7 +155,7 @@ class ClientObject(Generic[T]):
|
|
|
155
155
|
# type: (str|int, P_T, bool) -> Self
|
|
156
156
|
"""Sets property value"""
|
|
157
157
|
if persist_changes:
|
|
158
|
-
self.
|
|
158
|
+
self._properties_to_persist.append(name)
|
|
159
159
|
|
|
160
160
|
typed_value = self.get_property(name)
|
|
161
161
|
if isinstance(typed_value, (ClientObject, ClientValue)):
|
|
@@ -242,6 +242,14 @@ class ClientObject(Generic[T]):
|
|
|
242
242
|
def properties(self):
|
|
243
243
|
return self._properties
|
|
244
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
|
+
|
|
245
253
|
@property
|
|
246
254
|
def parent_collection(self):
|
|
247
255
|
"""Parent collection"""
|
|
@@ -254,7 +262,7 @@ class ClientObject(Generic[T]):
|
|
|
254
262
|
ser_prop_names = [n for n in self._properties.keys()]
|
|
255
263
|
include_control_info = False
|
|
256
264
|
else:
|
|
257
|
-
ser_prop_names = [n for n in self.
|
|
265
|
+
ser_prop_names = [n for n in self._properties_to_persist]
|
|
258
266
|
include_control_info = (
|
|
259
267
|
self.entity_type_name is not None
|
|
260
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
|
|
|
@@ -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
|
-
|
|
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)
|
|
@@ -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,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"
|
office365/search/entity.py
CHANGED
|
@@ -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(
|
|
20
|
-
|
|
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),
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
+
)
|
office365/search/entity_type.py
CHANGED
|
@@ -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"
|
office365/search/request.py
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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.
|
|
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
|
|
File without changes
|