Office365-REST-Python-Client 2.5.10__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.
Files changed (62) hide show
  1. {Office365_REST_Python_Client-2.5.10.dist-info → Office365_REST_Python_Client-2.5.11.dist-info}/METADATA +9 -10
  2. {Office365_REST_Python_Client-2.5.10.dist-info → Office365_REST_Python_Client-2.5.11.dist-info}/RECORD +62 -53
  3. {Office365_REST_Python_Client-2.5.10.dist-info → Office365_REST_Python_Client-2.5.11.dist-info}/WHEEL +1 -1
  4. office365/directory/identitygovernance/appconsent/request.py +32 -0
  5. office365/directory/identitygovernance/appconsent/request_scope.py +5 -0
  6. office365/directory/identitygovernance/privilegedaccess/group.py +5 -0
  7. office365/directory/identitygovernance/privilegedaccess/root.py +14 -0
  8. office365/directory/identitygovernance/privilegedaccess/schedule_instance.py +6 -0
  9. office365/directory/policies/admin_consent_request.py +10 -0
  10. office365/directory/policies/root.py +15 -0
  11. office365/directory/synchronization/status.py +14 -1
  12. office365/directory/synchronization/task_execution.py +5 -0
  13. office365/directory/users/user.py +4 -2
  14. office365/graph_client.py +7 -24
  15. office365/graph_request.py +24 -1
  16. office365/onedrive/driveitems/driveItem.py +41 -38
  17. office365/onedrive/listitems/list_item.py +1 -0
  18. office365/onedrive/lists/collection.py +6 -0
  19. office365/onedrive/sharepoint_ids.py +18 -1
  20. office365/onedrive/shares/drive_item.py +1 -2
  21. office365/onedrive/storage/__init__.py +0 -0
  22. office365/onedrive/storage/storage.py +5 -0
  23. office365/onedrive/workbooks/filter.py +7 -0
  24. office365/onedrive/workbooks/filter_criteria.py +9 -2
  25. office365/onedrive/workbooks/tables/rows/collection.py +20 -0
  26. office365/onedrive/workbooks/tables/rows/row.py +2 -1
  27. office365/onedrive/workbooks/workbook.py +7 -5
  28. office365/onenote/internal/multipart_page_query.py +2 -3
  29. office365/outlook/category.py +7 -0
  30. office365/outlook/mail/item_body.py +10 -1
  31. office365/outlook/mail/messages/collection.py +3 -0
  32. office365/outlook/mail/messages/message.py +3 -4
  33. office365/runtime/auth/providers/saml_token_provider.py +4 -4
  34. office365/runtime/http/request_options.py +7 -3
  35. office365/runtime/queries/create_entity.py +6 -8
  36. office365/runtime/queries/update_entity.py +3 -5
  37. office365/sharepoint/attachments/attachment.py +14 -2
  38. office365/sharepoint/attachments/collection.py +27 -4
  39. office365/sharepoint/changes/app_consent_principal.py +5 -0
  40. office365/sharepoint/changes/file.py +4 -0
  41. office365/sharepoint/documentmanagement/document_set.py +7 -8
  42. office365/sharepoint/fields/builtin_field_id.py +19 -0
  43. office365/sharepoint/fields/choice.py +2 -2
  44. office365/sharepoint/fields/collection.py +1 -3
  45. office365/sharepoint/fields/field.py +5 -2
  46. office365/sharepoint/files/file.py +1 -1
  47. office365/sharepoint/internal/queries/upload_file.py +12 -8
  48. office365/sharepoint/navigation/node.py +4 -2
  49. office365/sharepoint/packaging/app_details.py +34 -0
  50. office365/sharepoint/policy/dlp_policy_tip.py +9 -1
  51. office365/sharepoint/portal/sites/manager.py +1 -1
  52. office365/sharepoint/principal/principal.py +10 -1
  53. office365/sharepoint/principal/users/collection.py +1 -3
  54. office365/sharepoint/publishing/sites/communication/site.py +4 -3
  55. office365/sharepoint/request.py +33 -1
  56. office365/sharepoint/sharing/information.py +5 -0
  57. office365/sharepoint/sharing/permission_collection.py +13 -9
  58. office365/sharepoint/sharing/recipient_limits.py +9 -0
  59. office365/sharepoint/sharing/site_sharing_report_helper.py +2 -3
  60. office365/sharepoint/tenant/administration/tenant.py +22 -0
  61. {Office365_REST_Python_Client-2.5.10.dist-info → Office365_REST_Python_Client-2.5.11.dist-info}/LICENSE +0 -0
  62. {Office365_REST_Python_Client-2.5.10.dist-info → Office365_REST_Python_Client-2.5.11.dist-info}/top_level.txt +0 -0
@@ -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='commercial'):
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
- "User-Agent"
286
- ] = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"
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
  )
@@ -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 = None
16
+ self.data = data
15
17
  self.headers = {}
16
18
  self.auth = None
17
- self.method = HttpMethod.Get
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 typing import IO, AnyStr
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)
@@ -0,0 +1,5 @@
1
+ from office365.sharepoint.changes.change import Change
2
+
3
+
4
+ class ChangeAppConsentPrincipal(Change):
5
+ """"""
@@ -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)
@@ -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.before_execute(_construct_request)
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
@@ -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."""
@@ -1,5 +1,5 @@
1
- from office365.sharepoint.fields.field import Field
1
+ from office365.sharepoint.fields.multi_choice import FieldMultiChoice
2
2
 
3
3
 
4
- class FieldChoice(Field):
4
+ class FieldChoice(FieldMultiChoice):
5
5
  """Represents a choice field control."""
@@ -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.create_field_from_type(
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 create_field_from_type(context, field_parameters):
69
+ def create_field(context, field_parameters):
67
70
  """
68
71
  Creates a field based on its type
69
72
 
@@ -684,7 +684,7 @@ class File(AbstractFile):
684
684
  chunk_downloaded(bytes_read)
685
685
  file_object.write(chunk)
686
686
 
687
- self.context.add_query(qry).before_execute(
687
+ self.context.add_query(qry).before_query_execute(
688
688
  _construct_request
689
689
  ).after_execute(_process_response)
690
690
 
@@ -1,20 +1,24 @@
1
+ from typing import IO, TYPE_CHECKING
2
+
1
3
  from office365.runtime.http.http_method import HttpMethod
4
+ from office365.runtime.http.request_options import RequestOptions
2
5
  from office365.runtime.queries.service_operation import ServiceOperationQuery
3
6
 
7
+ if TYPE_CHECKING:
8
+ from office365.sharepoint.attachments.attachment import Attachment
9
+ from office365.sharepoint.files.file import File
4
10
 
5
- def create_upload_file_query(file, file_object):
6
- """
7
- Constructs upload file content query
8
11
 
9
- :type file: office365.sharepoint.files.file.File
10
- :type file_object: typing.IO
11
- """
12
+ def create_upload_file_query(file, file_object):
13
+ # type: (File|Attachment, IO) -> ServiceOperationQuery
14
+ """Constructs upload file content query"""
12
15
  qry = ServiceOperationQuery(file, "$value")
13
16
 
14
- def _construct_upload_request(request):
17
+ def _construct_request(request):
18
+ # type: (RequestOptions) -> None
15
19
  request.data = file_object.read()
16
20
  request.method = HttpMethod.Post
17
21
  request.set_header("X-HTTP-Method", "PUT")
18
22
 
19
- file.context.before_execute(_construct_upload_request)
23
+ file.context.before_execute(_construct_request)
20
24
  return qry
@@ -15,13 +15,14 @@ class NavigationNode(Entity):
15
15
  """
16
16
 
17
17
  def __str__(self):
18
- return self.title
18
+ return self.title or self.entity_type_name
19
19
 
20
20
  def __repr__(self):
21
- return self.url
21
+ return self.url or self.entity_type_name
22
22
 
23
23
  @property
24
24
  def children(self):
25
+ # type: () -> NavigationNodeCollection
25
26
  """Gets the collection of child nodes of the navigation node."""
26
27
  return self.properties.get(
27
28
  "Children",
@@ -49,6 +50,7 @@ class NavigationNode(Entity):
49
50
 
50
51
  @url.setter
51
52
  def url(self, value):
53
+ # type: (str) -> None
52
54
  """Sets a value that specifies the URL stored with the navigation node."""
53
55
  self.set_property("Url", value)
54
56
 
@@ -1,7 +1,41 @@
1
+ from typing import Optional
2
+
1
3
  from office365.sharepoint.entity import Entity
2
4
 
3
5
 
4
6
  class AppDetails(Entity):
7
+ """Specifies the detail properties for a SharePoint Add-in."""
8
+
9
+ @property
10
+ def eula_url(self):
11
+ # type: () -> Optional[str]
12
+ """Specifies the URL to get the End User License Agreement (EULA) information for the SharePoint Add-in."""
13
+ return self.properties.get("EulaUrl", None)
14
+
15
+ @property
16
+ def privacy_url(self):
17
+ # type: () -> Optional[str]
18
+ """Specifies the URL of the privacy statement for the SharePoint Add-in."""
19
+ return self.properties.get("PrivacyUrl", None)
20
+
21
+ @property
22
+ def publisher(self):
23
+ # type: () -> Optional[str]
24
+ """Specifies the publisher name for the SharePoint Add-in."""
25
+ return self.properties.get("Publisher", None)
26
+
27
+ @property
28
+ def short_description(self):
29
+ # type: () -> Optional[str]
30
+ """Specifies a short description for the SharePoint Add-in."""
31
+ return self.properties.get("ShortDescription", None)
32
+
33
+ @property
34
+ def support_url(self):
35
+ # type: () -> Optional[str]
36
+ """Specifies the URL of the support page for the SharePoint Add-in."""
37
+ return self.properties.get("SupportUrl", None)
38
+
5
39
  @property
6
40
  def entity_type_name(self):
7
41
  return "Microsoft.SharePoint.Packaging.AppDetails"
@@ -1,3 +1,6 @@
1
+ from datetime import datetime
2
+ from typing import Optional
3
+
1
4
  from office365.runtime.types.collections import StringCollection
2
5
  from office365.sharepoint.entity import Entity
3
6
 
@@ -7,23 +10,27 @@ class DlpPolicyTip(Entity):
7
10
 
8
11
  @property
9
12
  def applied_actions_text(self):
13
+ # type: () -> Optional[str]
10
14
  """Specifies the text which states what restrictive actions have been applied to this item."""
11
15
  return self.properties.get("AppliedActionsText", None)
12
16
 
13
17
  @property
14
18
  def compliance_url(self):
19
+ # type: () -> Optional[str]
15
20
  """Specifies the URL that provides additional help on the policy tip dialog."""
16
21
  return self.properties.get("ComplianceUrl", None)
17
22
 
18
23
  @property
19
24
  def general_text(self):
25
+ # type: () -> Optional[str]
20
26
  """General text that appears on the top of the policy tip dialog."""
21
27
  return self.properties.get("GeneralText", None)
22
28
 
23
29
  @property
24
30
  def last_processed_time(self):
31
+ # type: () -> Optional[datetime]
25
32
  """The last time this item was processed for policy matches."""
26
- return self.properties.get("LastProcessedTime", None)
33
+ return self.properties.get("LastProcessedTime", datetime.min)
27
34
 
28
35
  @property
29
36
  def matched_condition_descriptions(self):
@@ -37,5 +44,6 @@ class DlpPolicyTip(Entity):
37
44
 
38
45
  @property
39
46
  def two_letter_iso_language_name(self):
47
+ # type: () -> Optional[str]
40
48
  """The two-letter language code of the generated policy tip detail."""
41
49
  return self.properties.get("TwoLetterISOLanguageName", None)
@@ -80,7 +80,7 @@ class SPSiteManager(Entity):
80
80
  request.method = HttpMethod.Get
81
81
  request.url += "?url='{0}'".format(site_url)
82
82
 
83
- self.context.add_query(qry).before_execute(_construct_request)
83
+ self.context.add_query(qry).before_query_execute(_construct_request)
84
84
  return response
85
85
 
86
86
  def get_site_url(self, site_id):
@@ -11,7 +11,12 @@ class Principal(Entity):
11
11
  return self.title or self.entity_type_name
12
12
 
13
13
  def __repr__(self):
14
- return self.user_principal_name or self.id or self.entity_type_name
14
+ return (
15
+ self.user_principal_name
16
+ or self.login_name
17
+ or self.id
18
+ or self.entity_type_name
19
+ )
15
20
 
16
21
  @property
17
22
  def id(self):
@@ -55,6 +60,10 @@ class Principal(Entity):
55
60
  """Gets the type of the principal."""
56
61
  return self.properties.get("PrincipalType", None)
57
62
 
63
+ @property
64
+ def property_ref_name(self):
65
+ return "Id"
66
+
58
67
  def set_property(self, name, value, persist_changes=True):
59
68
  super(Principal, self).set_property(name, value, persist_changes)
60
69
  # fallback: create a new resource path
@@ -19,9 +19,7 @@ class UserCollection(EntityCollection[User]):
19
19
  self.add_child(return_type)
20
20
 
21
21
  def _create_and_add_query(login_name):
22
- """
23
- :type login_name: str
24
- """
22
+ # type: (str) -> None
25
23
  return_type.set_property("LoginName", login_name)
26
24
  qry = CreateEntityQuery(self, return_type, return_type)
27
25
  self.context.add_query(qry)
@@ -1,5 +1,6 @@
1
1
  from office365.runtime.client_result import ClientResult
2
2
  from office365.runtime.http.http_method import HttpMethod
3
+ from office365.runtime.http.request_options import RequestOptions
3
4
  from office365.runtime.queries.service_operation import ServiceOperationQuery
4
5
  from office365.sharepoint.entity import Entity
5
6
  from office365.sharepoint.publishing.sites.communication.creation_request import (
@@ -61,13 +62,13 @@ class CommunicationSite(Entity):
61
62
  qry = ServiceOperationQuery(
62
63
  self, "Status", None, {"url": site_url}, None, response
63
64
  )
64
- self.context.add_query(qry)
65
65
 
66
- def _construct_status_request(request):
66
+ def _construct_request(request):
67
+ # type: (RequestOptions) -> None
67
68
  request.method = HttpMethod.Get
68
69
  request.url += "?url='{0}'".format(site_url)
69
70
 
70
- self.context.before_execute(_construct_status_request)
71
+ self.context.add_query(qry).before_query_execute(_construct_request)
71
72
  return response
72
73
 
73
74
  def enable(self, design_package_id):
@@ -1,7 +1,39 @@
1
+ from typing import Optional
2
+
3
+ from requests import Response
4
+ from typing_extensions import Self
5
+
6
+ from office365.runtime.auth.authentication_context import AuthenticationContext
7
+ from office365.runtime.auth.client_credential import ClientCredential
8
+ from office365.runtime.auth.user_credential import UserCredential
9
+ from office365.runtime.http.request_options import RequestOptions
1
10
  from office365.runtime.odata.request import ODataRequest
2
11
  from office365.runtime.odata.v3.json_light_format import JsonLightFormat
3
12
 
4
13
 
5
14
  class SharePointRequest(ODataRequest):
6
- def __init__(self):
15
+ def __init__(self, base_url):
7
16
  super().__init__(JsonLightFormat())
17
+ self._auth_context = AuthenticationContext(url=base_url)
18
+ self.beforeExecute += self._authenticate_request
19
+
20
+ def execute_request(self, path):
21
+ # type: (str) -> Response
22
+ request_url = "{0}/_api/{1}".format(self._auth_context.url, path)
23
+ return self.execute_request_direct(RequestOptions(request_url))
24
+
25
+ def with_credentials(self, credentials, environment="commercial"):
26
+ # type: (UserCredential|ClientCredential, Optional[str]) -> Self
27
+ """
28
+ Initializes a client to acquire a token via user or client credentials
29
+ :type credentials: UserCredential or ClientCredential
30
+ :param str environment: The Office 365 Cloud Environment endpoint used for authentication
31
+ defaults to 'commercial'.
32
+ """
33
+ self._auth_context.with_credentials(credentials, environment=environment)
34
+ return self
35
+
36
+ def _authenticate_request(self, request):
37
+ # type: (RequestOptions) -> None
38
+ """Authenticate request"""
39
+ self._auth_context.authenticate_request(request)
@@ -22,6 +22,11 @@ class SharingInformation(Entity):
22
22
  """
23
23
  return self.properties.get("accessRequestSettings", AccessRequestSettings())
24
24
 
25
+ @property
26
+ def anonymous_link_expiration_restriction_days(self):
27
+ """Tenant's anonymous link expiration restriction in days."""
28
+ return self.properties.get("anonymousLinkExpirationRestrictionDays", None)
29
+
25
30
  @property
26
31
  def permissions_information(self):
27
32
  """