Skip to content

Commit 8b39315

Browse files
committed
examples update
1 parent 8213d73 commit 8b39315

File tree

19 files changed

+283
-9
lines changed

19 files changed

+283
-9
lines changed

examples/sharepoint/files/download_from_url.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
from office365.sharepoint.files.file import File
55
from tests import test_client_credentials, test_site_url
66

7-
abs_file_url = "{site_url}/sites/team/Shared Documents/big_buck_bunny.mp4".format(
8-
site_url=test_site_url
7+
abs_file_url = (
8+
"{site_url}/sites/team/Shared Documents/archive/big_buck_bunny.mp4".format(
9+
site_url=test_site_url
10+
)
911
)
1012

1113
with tempfile.TemporaryDirectory() as local_path:

examples/sharepoint/files/upload_large.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def print_upload_progress(offset):
2626
local_path = "../../../tests/data/big_buck_bunny.mp4"
2727
with open(local_path, "rb") as f:
2828
uploaded_file = target_folder.files.create_upload_session(
29-
f, size_chunk, print_upload_progress, "big_buck_bunny_v2.mp4"
29+
f, size_chunk, print_upload_progress
3030
).execute_query()
3131

3232
print("File {0} has been uploaded successfully".format(uploaded_file.serverRelativeUrl))
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Returns the user permissions for the file.
3+
"""
4+
5+
from pprint import pprint
6+
7+
from office365.sharepoint.client_context import ClientContext
8+
from tests import test_client_credentials, test_team_site_url
9+
10+
ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)
11+
file_url = "SitePages/Home.aspx"
12+
file = ctx.web.get_file_by_server_relative_url(file_url)
13+
result = file.listItemAllFields.get_user_effective_permissions(
14+
ctx.web.current_user
15+
).execute_query()
16+
pprint(result.value.permission_levels)

examples/sharepoint/views/__init__.py

Whitespace-only changes.

generator/metadata/SharePoint.xml

Lines changed: 117 additions & 2 deletions
Large diffs are not rendered by default.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from office365.entity import Entity
2+
3+
4+
class AuthenticationEventListener(Entity):
5+
"""
6+
Defines a listener to evaluate when an authentication event happens in an authentication experience.
7+
An authenticationListener is abstract and is the base class of the various types of listeners you can evaluate
8+
during an authentication event.
9+
"""

office365/directory/identities/container.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from office365.directory.authentication.conditions.event_listener import (
2+
AuthenticationEventListener,
3+
)
14
from office365.directory.identities.api_connector import IdentityApiConnector
25
from office365.directory.identities.conditional_access_root import ConditionalAccessRoot
36
from office365.directory.identities.providers.base_collection import (
@@ -18,6 +21,7 @@ class IdentityContainer(Entity):
1821

1922
@property
2023
def api_connectors(self):
24+
# type: () -> EntityCollection[IdentityApiConnector]
2125
"""Represents entry point for API connectors."""
2226
return self.properties.get(
2327
"apiConnectors",
@@ -28,6 +32,19 @@ def api_connectors(self):
2832
),
2933
)
3034

35+
@property
36+
def authentication_event_listeners(self):
37+
# type: () -> EntityCollection[AuthenticationEventListener]
38+
"""Get the collection of authenticationListener resources supported by the onSignupStart event."""
39+
return self.properties.get(
40+
"authenticationEventListeners",
41+
EntityCollection(
42+
self.context,
43+
AuthenticationEventListener,
44+
ResourcePath("authenticationEventListeners", self.resource_path),
45+
),
46+
)
47+
3148
@property
3249
def conditional_access(self):
3350
"""The entry point for the Conditional Access (CA) object model."""
@@ -76,6 +93,7 @@ def get_property(self, name, default_value=None):
7693
if default_value is None:
7794
property_mapping = {
7895
"apiConnectors": self.api_connectors,
96+
"authenticationEventListeners": self.authentication_event_listeners,
7997
"b2xUserFlows": self.b2x_user_flows,
8098
"conditionalAccess": self.conditional_access,
8199
"identityProviders": self.identity_providers,

office365/directory/security/attacksimulations/users/details.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@
33

44
class UserSimulationDetails(ClientValue):
55
"""Represents a user of a tenant and their online actions in an attack simulation and training campaign."""
6+
7+
def __init__(self, assigned_trainings_count=None):
8+
"""
9+
:param int assigned_trainings_count: Number of trainings assigned to a user in an attack simulation
10+
and training campaign.
11+
"""
12+
self.assignedTrainingsCount = assigned_trainings_count

office365/sharepoint/sites/version_policy_manager.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
from typing import Optional
2+
13
from office365.runtime.queries.service_operation import ServiceOperationQuery
24
from office365.sharepoint.entity import Entity
35

46

57
class SiteVersionPolicyManager(Entity):
68
""""""
79

10+
@property
11+
def major_version_limit(self):
12+
# type: () -> Optional[int]
13+
""" """
14+
return self.properties.get("MajorVersionLimit", None)
15+
816
def set_auto_expiration(self):
917
""""""
1018
qry = ServiceOperationQuery(self, "SetAutoExpiration")

0 commit comments

Comments
 (0)