Office365-REST-Python-Client 2.5.9__py3-none-any.whl → 2.5.11__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.9.dist-info → Office365_REST_Python_Client-2.5.11.dist-info}/METADATA +9 -10
- {Office365_REST_Python_Client-2.5.9.dist-info → Office365_REST_Python_Client-2.5.11.dist-info}/RECORD +82 -70
- {Office365_REST_Python_Client-2.5.9.dist-info → Office365_REST_Python_Client-2.5.11.dist-info}/WHEEL +1 -1
- office365/directory/identitygovernance/appconsent/request.py +32 -0
- office365/directory/identitygovernance/appconsent/request_scope.py +5 -0
- office365/directory/identitygovernance/privilegedaccess/group.py +5 -0
- office365/directory/identitygovernance/privilegedaccess/root.py +14 -0
- office365/directory/identitygovernance/privilegedaccess/schedule_instance.py +6 -0
- office365/directory/policies/admin_consent_request.py +10 -0
- office365/directory/policies/root.py +15 -0
- office365/directory/synchronization/status.py +14 -1
- office365/directory/synchronization/task_execution.py +5 -0
- office365/directory/users/user.py +4 -2
- office365/graph_client.py +7 -24
- office365/graph_request.py +24 -1
- office365/onedrive/driveitems/driveItem.py +41 -38
- office365/onedrive/internal/paths/url.py +14 -0
- office365/onedrive/listitems/list_item.py +1 -0
- office365/onedrive/lists/collection.py +6 -0
- office365/onedrive/sharepoint_ids.py +18 -1
- office365/onedrive/shares/drive_item.py +1 -2
- office365/onedrive/sitepages/horizontal_section_column.py +1 -1
- office365/onedrive/sitepages/site_page.py +1 -1
- office365/onedrive/sitepages/vertical_section.py +1 -1
- office365/onedrive/sitepages/webparts/__init__.py +0 -0
- office365/onedrive/sitepages/webparts/standard.py +5 -0
- office365/onedrive/sitepages/webparts/text.py +5 -0
- office365/onedrive/storage/__init__.py +0 -0
- office365/onedrive/storage/storage.py +5 -0
- office365/onedrive/workbooks/filter.py +7 -0
- office365/onedrive/workbooks/filter_criteria.py +9 -2
- office365/onedrive/workbooks/tables/rows/collection.py +20 -0
- office365/onedrive/workbooks/tables/rows/row.py +2 -1
- office365/onedrive/workbooks/workbook.py +7 -5
- office365/onenote/internal/multipart_page_query.py +2 -3
- office365/outlook/category.py +7 -0
- office365/outlook/mail/item_body.py +10 -1
- office365/outlook/mail/messages/collection.py +3 -0
- office365/outlook/mail/messages/message.py +3 -4
- office365/runtime/auth/providers/saml_token_provider.py +4 -4
- office365/runtime/client_object.py +4 -3
- office365/runtime/client_request.py +1 -1
- office365/runtime/client_runtime_context.py +3 -3
- office365/runtime/http/request_options.py +7 -3
- office365/runtime/paths/resource_path.py +3 -0
- office365/runtime/queries/create_entity.py +6 -8
- office365/runtime/queries/update_entity.py +3 -5
- office365/sharepoint/attachments/attachment.py +14 -2
- office365/sharepoint/attachments/collection.py +27 -4
- office365/sharepoint/businessdata/infrastructure/securestore/connection_settings.py +23 -1
- office365/sharepoint/changes/app_consent_principal.py +5 -0
- office365/sharepoint/changes/file.py +4 -0
- office365/sharepoint/directory/membership_result.py +5 -0
- office365/sharepoint/documentmanagement/document_set.py +7 -8
- office365/sharepoint/entity.py +5 -0
- office365/sharepoint/fields/builtin_field_id.py +19 -0
- office365/sharepoint/fields/choice.py +2 -2
- office365/sharepoint/fields/collection.py +1 -3
- office365/sharepoint/fields/field.py +5 -2
- office365/sharepoint/files/file.py +1 -1
- office365/sharepoint/internal/queries/upload_file.py +12 -8
- office365/sharepoint/lists/list.py +3 -2
- office365/sharepoint/navigation/node.py +4 -2
- office365/sharepoint/packaging/app_details.py +34 -0
- office365/sharepoint/policy/dlp_policy_tip.py +9 -1
- office365/sharepoint/portal/sites/manager.py +1 -1
- office365/sharepoint/principal/principal.py +10 -1
- office365/sharepoint/principal/users/collection.py +1 -3
- office365/sharepoint/publishing/sites/communication/site.py +4 -3
- office365/sharepoint/request.py +33 -1
- office365/sharepoint/search/service.py +5 -3
- office365/sharepoint/sharing/information.py +5 -0
- office365/sharepoint/sharing/permission_collection.py +13 -9
- office365/sharepoint/sharing/recipient_limits.py +9 -0
- office365/sharepoint/sharing/site_sharing_report_helper.py +2 -3
- office365/sharepoint/tenant/administration/tenant.py +22 -0
- office365/sharepoint/tenant/management/office365_tenant.py +18 -0
- office365/sharepoint/userprofiles/profile_loader.py +1 -3
- office365/sharepoint/userprofiles/user_profile.py +80 -6
- {Office365_REST_Python_Client-2.5.9.dist-info → Office365_REST_Python_Client-2.5.11.dist-info}/LICENSE +0 -0
- {Office365_REST_Python_Client-2.5.9.dist-info → Office365_REST_Python_Client-2.5.11.dist-info}/top_level.txt +0 -0
- /office365/onedrive/sitepages/{web_part.py → webparts/web_part.py} +0 -0
|
@@ -4,7 +4,14 @@ from office365.runtime.client_value import ClientValue
|
|
|
4
4
|
class WorkbookFilterCriteria(ClientValue):
|
|
5
5
|
"""Represents the filtering criteria applied to a column."""
|
|
6
6
|
|
|
7
|
-
def __init__(self, operator=None, values=None):
|
|
8
|
-
"""
|
|
7
|
+
def __init__(self, color=None, dynamicCriteria=None, operator=None, values=None):
|
|
8
|
+
"""
|
|
9
|
+
:param str color: The color applied to the cell.
|
|
10
|
+
:param str dynamicCriteria: A dynamic formula specified in a custom filter.
|
|
11
|
+
:param str operator: An operator in a cell; for example, =, >, <, <=, or <>.
|
|
12
|
+
:param list values: The values that appear in the cell.
|
|
13
|
+
"""
|
|
14
|
+
self.color = color
|
|
15
|
+
self.dynamicCriteria = dynamicCriteria
|
|
9
16
|
self.operator = operator
|
|
10
17
|
self.values = values
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from office365.entity_collection import EntityCollection
|
|
2
2
|
from office365.onedrive.workbooks.tables.rows.row import WorkbookTableRow
|
|
3
|
+
from office365.runtime.client_result import ClientResult
|
|
4
|
+
from office365.runtime.queries.function import FunctionQuery
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
class WorkbookTableRowCollection(EntityCollection[WorkbookTableRow]):
|
|
@@ -25,3 +27,21 @@ class WorkbookTableRowCollection(EntityCollection[WorkbookTableRow]):
|
|
|
25
27
|
Any rows below the inserted row are shifted downwards. Zero-indexed.
|
|
26
28
|
"""
|
|
27
29
|
return super(WorkbookTableRowCollection, self).add(values=values, index=index)
|
|
30
|
+
|
|
31
|
+
def count(self):
|
|
32
|
+
""""""
|
|
33
|
+
return_type = ClientResult(self.context, int())
|
|
34
|
+
qry = FunctionQuery(self, "count", None, return_type)
|
|
35
|
+
self.context.add_query(qry)
|
|
36
|
+
return return_type
|
|
37
|
+
|
|
38
|
+
def item_at(self, index):
|
|
39
|
+
# type: (int) -> WorkbookTableRow
|
|
40
|
+
"""Gets a row based on its position in the collection.
|
|
41
|
+
:param int index: Index value of the object to be retrieved. Zero-indexed.
|
|
42
|
+
"""
|
|
43
|
+
return_type = WorkbookTableRow(self.context)
|
|
44
|
+
self.add_child(return_type)
|
|
45
|
+
qry = FunctionQuery(self, "itemAt", [index], return_type)
|
|
46
|
+
self.context.add_query(qry)
|
|
47
|
+
return return_type
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Optional
|
|
1
|
+
from typing import List, Optional
|
|
2
2
|
|
|
3
3
|
from office365.entity import Entity
|
|
4
4
|
|
|
@@ -14,6 +14,7 @@ class WorkbookTableRow(Entity):
|
|
|
14
14
|
|
|
15
15
|
@property
|
|
16
16
|
def values(self):
|
|
17
|
+
# type: () -> Optional[List]
|
|
17
18
|
"""
|
|
18
19
|
Represents the raw values of the specified range. The data returned could be of type string, number,
|
|
19
20
|
or a boolean. Cell that contain an error will return the error string.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing_extensions import Self
|
|
2
|
+
|
|
1
3
|
from office365.entity import Entity
|
|
2
4
|
from office365.entity_collection import EntityCollection
|
|
3
5
|
from office365.onedrive.workbooks.applications.application import WorkbookApplication
|
|
@@ -50,20 +52,21 @@ class Workbook(Entity):
|
|
|
50
52
|
return return_type
|
|
51
53
|
|
|
52
54
|
def refresh_session(self, session_id):
|
|
55
|
+
# type: (str) -> Self
|
|
53
56
|
"""Use this API to refresh an existing workbook session.
|
|
54
57
|
:param str session_id: Identifier of the workbook session
|
|
55
58
|
"""
|
|
56
|
-
qry = ServiceOperationQuery(self, "refreshSession")
|
|
57
|
-
self.context.add_query(qry)
|
|
58
59
|
|
|
59
60
|
def _construct_request(request):
|
|
60
61
|
# type: (RequestOptions) -> None
|
|
61
62
|
request.set_header("workbook-session-id", session_id)
|
|
62
63
|
|
|
63
|
-
self
|
|
64
|
+
qry = ServiceOperationQuery(self, "refreshSession")
|
|
65
|
+
self.context.add_query(qry).before_query_execute(_construct_request)
|
|
64
66
|
return self
|
|
65
67
|
|
|
66
68
|
def close_session(self, session_id):
|
|
69
|
+
# type: (str) -> Self
|
|
67
70
|
"""Use this API to close an existing workbook session.
|
|
68
71
|
:param str session_id: Identifier of the workbook session
|
|
69
72
|
"""
|
|
@@ -73,8 +76,7 @@ class Workbook(Entity):
|
|
|
73
76
|
# type: (RequestOptions) -> None
|
|
74
77
|
request.set_header("workbook-session-id", session_id)
|
|
75
78
|
|
|
76
|
-
self.context.
|
|
77
|
-
self.context.add_query(qry)
|
|
79
|
+
self.context.add_query(qry).before_query_execute(_construct_request)
|
|
78
80
|
return self
|
|
79
81
|
|
|
80
82
|
@property
|
|
@@ -3,6 +3,7 @@ from typing import AnyStr
|
|
|
3
3
|
|
|
4
4
|
from office365.runtime.compat import get_mime_type, message_as_bytes_or_string
|
|
5
5
|
from office365.runtime.http.http_method import HttpMethod
|
|
6
|
+
from office365.runtime.http.request_options import RequestOptions
|
|
6
7
|
from office365.runtime.queries.batch import create_boundary
|
|
7
8
|
from office365.runtime.queries.client_query import ClientQuery
|
|
8
9
|
|
|
@@ -32,9 +33,7 @@ class OneNotePageCreateQuery(ClientQuery):
|
|
|
32
33
|
self._files = attachment_files
|
|
33
34
|
|
|
34
35
|
def _construct_multipart_request(self, request):
|
|
35
|
-
|
|
36
|
-
:type request: office365.runtime.http.request_options.RequestOptions
|
|
37
|
-
"""
|
|
36
|
+
# type: (RequestOptions) -> None
|
|
38
37
|
request.method = HttpMethod.Post
|
|
39
38
|
boundary = create_boundary("PageBoundary", True)
|
|
40
39
|
request.set_header(
|
office365/outlook/category.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
1
3
|
from office365.entity import Entity
|
|
2
4
|
|
|
3
5
|
|
|
@@ -6,13 +8,18 @@ class OutlookCategory(Entity):
|
|
|
6
8
|
The user defines categories in a master list, and can apply one or more
|
|
7
9
|
of these user-defined categories to an item."""
|
|
8
10
|
|
|
11
|
+
def __str__(self):
|
|
12
|
+
return self.display_name or self.entity_type_name
|
|
13
|
+
|
|
9
14
|
@property
|
|
10
15
|
def color(self):
|
|
16
|
+
# type: () -> Optional[str]
|
|
11
17
|
"""A pre-set color constant that characterizes a category, and that is mapped to one of 25 predefined colors"""
|
|
12
18
|
return self.properties.get("color", None)
|
|
13
19
|
|
|
14
20
|
@property
|
|
15
21
|
def display_name(self):
|
|
22
|
+
# type: () -> Optional[str]
|
|
16
23
|
"""A unique name that identifies a category in the user's mailbox.
|
|
17
24
|
After a category is created, the name cannot be changed"""
|
|
18
25
|
return self.properties.get("displayName", None)
|
|
@@ -6,7 +6,6 @@ class ItemBody(ClientValue):
|
|
|
6
6
|
|
|
7
7
|
def __init__(self, content=None, content_type="Text"):
|
|
8
8
|
"""
|
|
9
|
-
|
|
10
9
|
:param str content: The content of the item.
|
|
11
10
|
:param str content_type: The type of the content. Possible values are text and html.
|
|
12
11
|
"""
|
|
@@ -14,5 +13,15 @@ class ItemBody(ClientValue):
|
|
|
14
13
|
self.content = content
|
|
15
14
|
self.contentType = content_type
|
|
16
15
|
|
|
16
|
+
@staticmethod
|
|
17
|
+
def text(content):
|
|
18
|
+
# type: (str) -> "ItemBody"
|
|
19
|
+
return ItemBody(content)
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def html(content):
|
|
23
|
+
# type: (str) -> "ItemBody"
|
|
24
|
+
return ItemBody(content, "html")
|
|
25
|
+
|
|
17
26
|
def __repr__(self):
|
|
18
27
|
return self.content
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
1
3
|
from office365.delta_collection import DeltaCollection
|
|
2
4
|
from office365.outlook.mail.item_body import ItemBody
|
|
3
5
|
from office365.outlook.mail.messages.message import Message
|
|
@@ -10,6 +12,7 @@ class MessageCollection(DeltaCollection[Message]):
|
|
|
10
12
|
super(MessageCollection, self).__init__(context, Message, resource_path)
|
|
11
13
|
|
|
12
14
|
def add(self, subject=None, body=None, to_recipients=None, **kwargs):
|
|
15
|
+
# type: (str, str|ItemBody, List[str], ...) -> Message
|
|
13
16
|
"""
|
|
14
17
|
Create a draft of a new message in either JSON or MIME format.
|
|
15
18
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import uuid
|
|
3
3
|
from datetime import datetime
|
|
4
|
-
from typing import IO, AnyStr, Optional
|
|
4
|
+
from typing import IO, AnyStr, List, Optional
|
|
5
5
|
|
|
6
6
|
from typing_extensions import Self
|
|
7
7
|
|
|
@@ -42,6 +42,7 @@ class Message(OutlookItem):
|
|
|
42
42
|
return self
|
|
43
43
|
|
|
44
44
|
def create_forward(self, to_recipients=None, message=None, comment=None):
|
|
45
|
+
# type: (List[Recipient], "Message", str) -> Message
|
|
45
46
|
"""
|
|
46
47
|
Create a draft to forward an existing message, in either JSON or MIME format.
|
|
47
48
|
|
|
@@ -373,9 +374,7 @@ class Message(OutlookItem):
|
|
|
373
374
|
@property
|
|
374
375
|
def subject(self):
|
|
375
376
|
# type: () -> Optional[str]
|
|
376
|
-
"""
|
|
377
|
-
The subject of the message.
|
|
378
|
-
"""
|
|
377
|
+
"""The subject of the message."""
|
|
379
378
|
return self.properties.get("subject", None)
|
|
380
379
|
|
|
381
380
|
@subject.setter
|
|
@@ -40,7 +40,7 @@ def is_valid_auth_cookies(values):
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
class SamlTokenProvider(AuthenticationProvider, office365.logger.LoggerContext):
|
|
43
|
-
def __init__(self, url, username, password, browser_mode, environment=
|
|
43
|
+
def __init__(self, url, username, password, browser_mode, environment="commercial"):
|
|
44
44
|
"""
|
|
45
45
|
SAML Security Token Service provider (claims-based authentication)
|
|
46
46
|
|
|
@@ -281,9 +281,9 @@ class SamlTokenProvider(AuthenticationProvider, office365.logger.LoggerContext):
|
|
|
281
281
|
if not federated or self._browser_mode:
|
|
282
282
|
headers = {"Content-Type": "application/x-www-form-urlencoded"}
|
|
283
283
|
if self._browser_mode:
|
|
284
|
-
headers[
|
|
285
|
-
"
|
|
286
|
-
|
|
284
|
+
headers["User-Agent"] = (
|
|
285
|
+
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"
|
|
286
|
+
)
|
|
287
287
|
session.post(
|
|
288
288
|
self._sts_profile.signin_page_url, data=security_token, headers=headers
|
|
289
289
|
)
|
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import datetime
|
|
4
4
|
from typing import TYPE_CHECKING, Any, Callable, Generic, List, Optional, TypeVar
|
|
5
5
|
|
|
6
|
+
from requests import Response
|
|
6
7
|
from typing_extensions import Self
|
|
7
8
|
|
|
8
9
|
from office365.runtime.client_runtime_context import ClientRuntimeContext
|
|
@@ -80,10 +81,10 @@ class ClientObject(Generic[T]):
|
|
|
80
81
|
self.context.before_execute(action)
|
|
81
82
|
return self
|
|
82
83
|
|
|
83
|
-
def after_execute(self, action, execute_first=False):
|
|
84
|
-
# type: (Callable[[Self], None], bool) -> Self
|
|
84
|
+
def after_execute(self, action, execute_first=False, include_response=False):
|
|
85
|
+
# type: (Callable[[Self|Response], None], bool, bool) -> Self
|
|
85
86
|
"""Attach an event handler to client object which gets triggered after query is submitted to server"""
|
|
86
|
-
self.context.after_query_execute(action, execute_first)
|
|
87
|
+
self.context.after_query_execute(action, execute_first, include_response)
|
|
87
88
|
return self
|
|
88
89
|
|
|
89
90
|
def get(self):
|
|
@@ -35,7 +35,6 @@ class ClientRequest(object):
|
|
|
35
35
|
try:
|
|
36
36
|
request = self.build_request(query)
|
|
37
37
|
response = self.execute_request_direct(request)
|
|
38
|
-
response.raise_for_status()
|
|
39
38
|
self.process_response(response, query)
|
|
40
39
|
self.afterExecute.notify(response)
|
|
41
40
|
except HTTPError as e:
|
|
@@ -99,4 +98,5 @@ class ClientRequest(object):
|
|
|
99
98
|
stream=request.stream,
|
|
100
99
|
proxies=request.proxies,
|
|
101
100
|
)
|
|
101
|
+
response.raise_for_status()
|
|
102
102
|
return response
|
|
@@ -126,8 +126,8 @@ class ClientRuntimeContext(object):
|
|
|
126
126
|
self.pending_request().beforeExecute += _process_request
|
|
127
127
|
return self
|
|
128
128
|
|
|
129
|
-
def after_query_execute(self, action, execute_first=False):
|
|
130
|
-
# type: (Callable[[T], None], bool) -> Self
|
|
129
|
+
def after_query_execute(self, action, execute_first=False, include_response=False):
|
|
130
|
+
# type: (Callable[[T|Response], None], bool, bool) -> Self
|
|
131
131
|
"""Attach an event handler which is triggered after query is submitted to server"""
|
|
132
132
|
if len(self._queries) == 0:
|
|
133
133
|
return
|
|
@@ -138,7 +138,7 @@ class ClientRuntimeContext(object):
|
|
|
138
138
|
resp.raise_for_status()
|
|
139
139
|
if self.current_query.id == query.id:
|
|
140
140
|
self.pending_request().afterExecute -= _process_response
|
|
141
|
-
action(query.return_type)
|
|
141
|
+
action(resp if include_response else query.return_type)
|
|
142
142
|
|
|
143
143
|
self.pending_request().afterExecute += _process_response
|
|
144
144
|
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
1
3
|
from office365.runtime.http.http_method import HttpMethod
|
|
2
4
|
|
|
3
5
|
|
|
4
6
|
class RequestOptions(object):
|
|
5
7
|
"""Request options"""
|
|
6
8
|
|
|
7
|
-
def __init__(self, url):
|
|
9
|
+
def __init__(self, url, method=HttpMethod.Get, data=None):
|
|
8
10
|
"""
|
|
9
11
|
Request options
|
|
10
12
|
|
|
11
13
|
:param str url: URL for the new :class:`requests.Request` object
|
|
12
14
|
"""
|
|
13
15
|
self.url = url
|
|
14
|
-
self.data =
|
|
16
|
+
self.data = data
|
|
15
17
|
self.headers = {}
|
|
16
18
|
self.auth = None
|
|
17
|
-
self.method =
|
|
19
|
+
self.method = method
|
|
18
20
|
self.verify = True
|
|
19
21
|
self.stream = False
|
|
20
22
|
self.proxies = None
|
|
@@ -28,8 +30,10 @@ class RequestOptions(object):
|
|
|
28
30
|
return hasattr(self.data, "decode") and callable(self.data.decode)
|
|
29
31
|
|
|
30
32
|
def set_header(self, name, value):
|
|
33
|
+
# type: (str, Any) -> None
|
|
31
34
|
self.headers[name] = value
|
|
32
35
|
|
|
33
36
|
def ensure_header(self, name, value):
|
|
37
|
+
# type: (str, Any) -> None
|
|
34
38
|
if name not in self.headers:
|
|
35
39
|
self.headers[name] = value
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
+
from typing import Dict
|
|
2
|
+
|
|
3
|
+
from office365.runtime.client_object import ClientObject
|
|
4
|
+
from office365.runtime.client_value import ClientValue
|
|
1
5
|
from office365.runtime.queries.client_query import ClientQuery
|
|
2
6
|
|
|
3
7
|
|
|
4
8
|
class CreateEntityQuery(ClientQuery):
|
|
5
9
|
def __init__(self, parent_entity, parameters, return_type=None):
|
|
6
|
-
|
|
7
|
-
Create entity query
|
|
8
|
-
|
|
9
|
-
:type return_type: office365.runtime.client_object.ClientObject
|
|
10
|
-
:type parameters: office365.runtime.client_object.ClientObject or office365.runtime.client_value.ClientValue
|
|
11
|
-
or dict
|
|
12
|
-
:type parent_entity: office365.runtime.client_object.ClientObject
|
|
13
|
-
"""
|
|
10
|
+
# type: (ClientObject, ClientObject|ClientValue|Dict, ClientObject) -> None
|
|
11
|
+
"""Create entity query"""
|
|
14
12
|
super(CreateEntityQuery, self).__init__(
|
|
15
13
|
parent_entity.context, parent_entity, parameters, None, return_type
|
|
16
14
|
)
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
from office365.runtime.client_object import ClientObject
|
|
1
2
|
from office365.runtime.queries.client_query import ClientQuery
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class UpdateEntityQuery(ClientQuery):
|
|
5
6
|
def __init__(self, update_type):
|
|
6
|
-
|
|
7
|
-
Update client object query
|
|
8
|
-
|
|
9
|
-
:type update_type: office365.runtime.client_object.ClientObject
|
|
10
|
-
"""
|
|
7
|
+
# type: (ClientObject) -> None
|
|
8
|
+
"""Update client object query"""
|
|
11
9
|
super(UpdateEntityQuery, self).__init__(
|
|
12
10
|
update_type.context, update_type, update_type
|
|
13
11
|
)
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
from typing import AnyStr, Optional
|
|
1
|
+
from typing import IO, AnyStr, Optional
|
|
2
|
+
|
|
3
|
+
from typing_extensions import Self
|
|
2
4
|
|
|
3
5
|
from office365.runtime.client_result import ClientResult
|
|
6
|
+
from office365.runtime.queries.function import FunctionQuery
|
|
4
7
|
from office365.runtime.queries.service_operation import ServiceOperationQuery
|
|
5
8
|
from office365.sharepoint.entity import Entity
|
|
6
9
|
from office365.sharepoint.internal.queries.upload_file import create_upload_file_query
|
|
@@ -42,6 +45,14 @@ class Attachment(Entity):
|
|
|
42
45
|
self.ensure_property("ServerRelativeUrl", _download_file_by_url)
|
|
43
46
|
return self
|
|
44
47
|
|
|
48
|
+
def get_content(self):
|
|
49
|
+
# type: () -> ClientResult[AnyStr]
|
|
50
|
+
"""Gets the raw contents of attachment"""
|
|
51
|
+
return_type = ClientResult(self.context)
|
|
52
|
+
qry = FunctionQuery(self, "$value", None, return_type)
|
|
53
|
+
self.context.add_query(qry)
|
|
54
|
+
return return_type
|
|
55
|
+
|
|
45
56
|
def recycle_object(self):
|
|
46
57
|
"""Move this attachment to site recycle bin."""
|
|
47
58
|
qry = ServiceOperationQuery(self, "RecycleObject")
|
|
@@ -49,6 +60,7 @@ class Attachment(Entity):
|
|
|
49
60
|
return self
|
|
50
61
|
|
|
51
62
|
def upload(self, file_object, use_path=True):
|
|
63
|
+
# type: (IO, bool) -> Self
|
|
52
64
|
"""
|
|
53
65
|
Upload attachment into list item
|
|
54
66
|
|
|
@@ -90,7 +102,7 @@ class Attachment(Entity):
|
|
|
90
102
|
@property
|
|
91
103
|
def server_relative_url(self):
|
|
92
104
|
# type: () -> Optional[str]
|
|
93
|
-
""" """
|
|
105
|
+
"""The server-relative-url of the attachment"""
|
|
94
106
|
return self.properties.get("ServerRelativeUrl", None)
|
|
95
107
|
|
|
96
108
|
@property
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from
|
|
2
|
+
from functools import partial
|
|
3
|
+
from typing import IO, AnyStr, Callable, Optional
|
|
3
4
|
|
|
5
|
+
from typing_extensions import Self
|
|
6
|
+
|
|
7
|
+
from office365.runtime.client_result import ClientResult
|
|
4
8
|
from office365.runtime.paths.service_operation import ServiceOperationPath
|
|
5
9
|
from office365.runtime.queries.service_operation import ServiceOperationQuery
|
|
6
10
|
from office365.sharepoint.attachments.attachment import Attachment
|
|
@@ -74,11 +78,30 @@ class AttachmentCollection(EntityCollection[Attachment]):
|
|
|
74
78
|
self.get().after_execute(_delete_all)
|
|
75
79
|
return self
|
|
76
80
|
|
|
81
|
+
def download(self, download_file, file_downloaded=None):
|
|
82
|
+
# type: (IO, Optional[Callable[[Attachment], None]]) -> Self
|
|
83
|
+
"""Downloads attachments as a zip file"""
|
|
84
|
+
import zipfile
|
|
85
|
+
|
|
86
|
+
def _file_downloaded(attachment_file, result):
|
|
87
|
+
# type: (Attachment, ClientResult[AnyStr]) -> None
|
|
88
|
+
with zipfile.ZipFile(download_file.name, "a", zipfile.ZIP_DEFLATED) as zf:
|
|
89
|
+
zf.writestr(attachment_file.file_name, result.value)
|
|
90
|
+
if callable(file_downloaded):
|
|
91
|
+
file_downloaded(attachment_file)
|
|
92
|
+
|
|
93
|
+
def _download(return_type):
|
|
94
|
+
for attachment_file in return_type:
|
|
95
|
+
attachment_file.get_content().after_execute(
|
|
96
|
+
partial(_file_downloaded, attachment_file)
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
self.get().after_execute(_download)
|
|
100
|
+
return self
|
|
101
|
+
|
|
77
102
|
def upload(self, file, use_path=True):
|
|
78
103
|
# type: (IO, bool) -> Attachment
|
|
79
|
-
"""
|
|
80
|
-
Uploads the attachment
|
|
81
|
-
"""
|
|
104
|
+
"""Uploads the attachment"""
|
|
82
105
|
info = AttachmentCreationInformation(os.path.basename(file.name), file.read())
|
|
83
106
|
if use_path:
|
|
84
107
|
return self.add_using_path(info.filename, info.content)
|
|
@@ -1,8 +1,30 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from office365.runtime.paths.resource_path import ResourcePath
|
|
1
4
|
from office365.sharepoint.entity import Entity
|
|
2
5
|
|
|
3
6
|
|
|
4
7
|
class ConnectionSettings(Entity):
|
|
5
|
-
""""""
|
|
8
|
+
"""The ConnectionSettings contains information about an endpoint (4) that can be used to connect to it."""
|
|
9
|
+
|
|
10
|
+
def __init__(self, context, resource_path=None):
|
|
11
|
+
if resource_path is None:
|
|
12
|
+
resource_path = ResourcePath(
|
|
13
|
+
"Microsoft.BusinessData.Infrastructure.SecureStore.ConnectionSettings"
|
|
14
|
+
)
|
|
15
|
+
super(ConnectionSettings, self).__init__(context, resource_path)
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def authentication_mode(self):
|
|
19
|
+
# type: () -> Optional[str]
|
|
20
|
+
"""The authentication mode used by the endpoint"""
|
|
21
|
+
return self.properties.get("AuthenticationMode", None)
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def parent_name(self):
|
|
25
|
+
# type: () -> Optional[str]
|
|
26
|
+
"""The unique name used to identify the parent of the endpoint"""
|
|
27
|
+
return self.properties.get("parentName", None)
|
|
6
28
|
|
|
7
29
|
@property
|
|
8
30
|
def entity_type_name(self):
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
1
3
|
from office365.sharepoint.changes.change import Change
|
|
2
4
|
|
|
3
5
|
|
|
@@ -6,10 +8,12 @@ class ChangeFile(Change):
|
|
|
6
8
|
|
|
7
9
|
@property
|
|
8
10
|
def unique_id(self):
|
|
11
|
+
# type: () -> Optional[str]
|
|
9
12
|
"""Identifies the file that changed."""
|
|
10
13
|
return self.properties.get("UniqueId", None)
|
|
11
14
|
|
|
12
15
|
@property
|
|
13
16
|
def web_id(self):
|
|
17
|
+
# type: () -> Optional[str]
|
|
14
18
|
"""Identifies the site that contains the changed file."""
|
|
15
19
|
return self.properties.get("WebId", None)
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
from office365.runtime.types.collections import StringCollection
|
|
1
2
|
from office365.sharepoint.entity import Entity
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class MembershipResult(Entity):
|
|
6
|
+
@property
|
|
7
|
+
def groups_list(self):
|
|
8
|
+
return self.properties.get("GroupsList", StringCollection())
|
|
9
|
+
|
|
5
10
|
@property
|
|
6
11
|
def entity_type_name(self):
|
|
7
12
|
return "SP.Directory.MembershipResult"
|
|
@@ -21,16 +21,9 @@ class DocumentSet(Folder):
|
|
|
21
21
|
|
|
22
22
|
return_type = DocumentSet(context)
|
|
23
23
|
|
|
24
|
-
def _parent_folder_loaded():
|
|
25
|
-
custom_props = parent_folder.get_property("Properties")
|
|
26
|
-
list_id = custom_props.get("vti_x005f_listname")
|
|
27
|
-
target_list = context.web.lists.get_by_id(list_id)
|
|
28
|
-
target_list.ensure_property("Title", _create, target_list=target_list)
|
|
29
|
-
|
|
30
24
|
def _create(target_list):
|
|
31
25
|
# type: (List) -> None
|
|
32
26
|
qry = ClientQuery(context, return_type=return_type)
|
|
33
|
-
context.add_query(qry)
|
|
34
27
|
folder_url = parent_folder.serverRelativeUrl + "/" + name
|
|
35
28
|
return_type.set_property("ServerRelativeUrl", folder_url)
|
|
36
29
|
|
|
@@ -43,7 +36,13 @@ class DocumentSet(Folder):
|
|
|
43
36
|
request.set_header("Slug", "{0}|{1}".format(folder_url, ct_id))
|
|
44
37
|
request.method = HttpMethod.Post
|
|
45
38
|
|
|
46
|
-
context.
|
|
39
|
+
context.add_query(qry).before_query_execute(_construct_request)
|
|
40
|
+
|
|
41
|
+
def _parent_folder_loaded():
|
|
42
|
+
custom_props = parent_folder.get_property("Properties")
|
|
43
|
+
list_id = custom_props.get("vti_x005f_listname")
|
|
44
|
+
target_list = context.web.lists.get_by_id(list_id)
|
|
45
|
+
target_list.ensure_property("Title", _create, target_list=target_list)
|
|
47
46
|
|
|
48
47
|
parent_folder.ensure_properties(
|
|
49
48
|
["UniqueId", "Properties", "ServerRelativeUrl"], _parent_folder_loaded
|
office365/sharepoint/entity.py
CHANGED
|
@@ -16,6 +16,11 @@ if TYPE_CHECKING:
|
|
|
16
16
|
class Entity(ClientObject):
|
|
17
17
|
"""SharePoint specific entity"""
|
|
18
18
|
|
|
19
|
+
def execute_query_with_incremental_retry(self, max_retry=5):
|
|
20
|
+
"""Handles throttling requests."""
|
|
21
|
+
self.context.execute_query_with_incremental_retry(max_retry)
|
|
22
|
+
return self
|
|
23
|
+
|
|
19
24
|
def execute_batch(self, items_per_batch=100, success_callback=None):
|
|
20
25
|
# type: (int, Callable[[int], None]) -> Self
|
|
21
26
|
"""Construct and submit to a server a batch request"""
|
|
@@ -9,3 +9,22 @@ class SPBuiltInFieldId:
|
|
|
9
9
|
|
|
10
10
|
FSObjType = "FSObjType"
|
|
11
11
|
"""Identifies a field that contains information about the file system type"""
|
|
12
|
+
|
|
13
|
+
FileType = "FileType"
|
|
14
|
+
"""Identifies a field that contains information about the file type for version history of the specified
|
|
15
|
+
SharePoint Foundation library picture object."""
|
|
16
|
+
|
|
17
|
+
FirstName = "FirstName"
|
|
18
|
+
"""Identifies a field that contains the first name for the specified SharePoint Foundation contact object."""
|
|
19
|
+
|
|
20
|
+
FormData = "FormData"
|
|
21
|
+
"""Identifies a field that contains the FormData property for the specified
|
|
22
|
+
Microsoft SharePoint Foundation contact object."""
|
|
23
|
+
|
|
24
|
+
FormURN = "FormURN"
|
|
25
|
+
"""Identifies a field that contains the FormURN property for the specified
|
|
26
|
+
Microsoft SharePoint Foundation contact object."""
|
|
27
|
+
|
|
28
|
+
fRecurrence = "fRecurrence"
|
|
29
|
+
"""Identifies a field that contains information about the recurrence field of the specified SharePoint Foundation
|
|
30
|
+
calendar event object."""
|
|
@@ -222,9 +222,7 @@ class FieldCollection(EntityCollection[Field]):
|
|
|
222
222
|
|
|
223
223
|
:type field_create_information: office365.sharepoint.fields.creation_information.FieldCreationInformation
|
|
224
224
|
"""
|
|
225
|
-
return_type = Field.
|
|
226
|
-
self.context, field_create_information
|
|
227
|
-
)
|
|
225
|
+
return_type = Field.create_field(self.context, field_create_information)
|
|
228
226
|
self.add_child(return_type)
|
|
229
227
|
qry = CreateEntityQuery(self, return_type, return_type)
|
|
230
228
|
self.context.add_query(qry)
|
|
@@ -14,8 +14,11 @@ class Field(Entity):
|
|
|
14
14
|
def __init__(self, context, resource_path=None):
|
|
15
15
|
super(Field, self).__init__(context, resource_path)
|
|
16
16
|
|
|
17
|
+
def __str__(self):
|
|
18
|
+
return self.title or self.entity_type_name
|
|
19
|
+
|
|
17
20
|
def __repr__(self):
|
|
18
|
-
return self.internal_name or self.id
|
|
21
|
+
return self.internal_name or self.id or self.entity_type_name
|
|
19
22
|
|
|
20
23
|
@staticmethod
|
|
21
24
|
def resolve_field_type(type_id_or_name):
|
|
@@ -63,7 +66,7 @@ class Field(Entity):
|
|
|
63
66
|
return Field
|
|
64
67
|
|
|
65
68
|
@staticmethod
|
|
66
|
-
def
|
|
69
|
+
def create_field(context, field_parameters):
|
|
67
70
|
"""
|
|
68
71
|
Creates a field based on its type
|
|
69
72
|
|