Skip to content

Commit de6254c

Browse files
committed
SharePoint model updates, improvements for addressing sharepoint resources
1 parent a255892 commit de6254c

File tree

21 files changed

+153
-5
lines changed

21 files changed

+153
-5
lines changed

examples/sharepoint/lists/clear.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def print_progress(items_count):
1111

1212

1313
ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)
14-
target_list = ctx.web.lists.get_by_title("Contacts_Large")
14+
target_list = ctx.web.lists.get_by_title("Company Tasks")
1515
target_list.clear().get().execute_batch()
1616
print("List items count: {0}".format(target_list.item_count))

examples/sharepoint/lists/export_view.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""
2+
3+
"""
14
import json
25

36
from office365.sharepoint.client_context import ClientContext
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
Exports user profile data.
3+
"""
4+
from office365.sharepoint.client_context import ClientContext
5+
from tests import test_client_credentials, test_site_url
6+
7+
client = ClientContext(test_site_url).with_credentials(test_client_credentials)
8+
users = (
9+
client.site.root_web.site_users.filter("IsHiddenInUI eq false")
10+
.get()
11+
.top(10)
12+
.execute_query()
13+
)
14+
15+
exported_data = {}
16+
for user in users:
17+
exported_data[user.login_name] = client.people_manager.get_properties_for(
18+
user.login_name
19+
)
20+
client.execute_batch()
21+
print(exported_data)

examples/sharepoint/userprofile/get_properties.py

Whitespace-only changes.

generator/import_metadata.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ def export_to_file(path, content):
2626
"--endpoint",
2727
dest="endpoint",
2828
help="Import metadata endpoint",
29-
default="sharepoint",
29+
default="microsoftgraph",
3030
)
3131
parser.add_argument(
3232
"-p",
3333
"--path",
3434
dest="path",
35-
default="./metadata/SharePoint.xml",
35+
default="./metadata/MicrosoftGraph.xml",
3636
help="Import metadata endpoint",
3737
)
3838

generator/metadata/MicrosoftGraph.xml

+16
Original file line numberDiff line numberDiff line change
@@ -4867,6 +4867,11 @@
48674867
<Annotations Target="microsoft.graph.bookingAppointment/anonymousJoinWebUrl">
48684868
<Annotation Term="Org.OData.Core.V1.IsURL" Bool="true"/>
48694869
</Annotations>
4870+
<Annotations Target="microsoft.graph.bookingAppointment/customerNotes">
4871+
<Annotation Term="Org.OData.Core.V1.Description" String="Notes from the customer associated with this appointment."/>
4872+
<Annotation Term="Org.OData.Core.V1.Immutable" Bool="true"/>
4873+
<Annotation Term="Org.OData.Core.V1.LongDescription" String="The value of this property is only available when reading an individual booking appointment by id. Its value can only be set when creating a new appointment with a new customer, ie, without specifying a CustomerId. After that, the property is computed from the customer represented by CustomerId."/>
4874+
</Annotations>
48704875
<Annotations Target="microsoft.graph.bookingAppointment/duration">
48714876
<Annotation Term="Org.OData.Core.V1.Computed" Bool="true"/>
48724877
</Annotations>
@@ -16248,6 +16253,12 @@
1624816253
<Member Name="outOfOffice" Value="3"/>
1624916254
<Member Name="unknownFutureValue" Value="4"/>
1625016255
</EnumType>
16256+
<EnumType Name="bookingStaffMembershipStatus">
16257+
<Member Name="active" Value="0"/>
16258+
<Member Name="pendingAcceptance" Value="1"/>
16259+
<Member Name="rejectedByStaff" Value="2"/>
16260+
<Member Name="unknownFutureValue" Value="3"/>
16261+
</EnumType>
1625116262
<EnumType Name="bookingStaffRole">
1625216263
<Member Name="guest" Value="0"/>
1625316264
<Member Name="administrator" Value="1"/>
@@ -22887,6 +22898,10 @@
2288722898
<EntityType Name="bookingAppointment" BaseType="graph.entity">
2288822899
<Property Name="additionalInformation" Type="Edm.String"/>
2288922900
<Property Name="anonymousJoinWebUrl" Type="Edm.String"/>
22901+
<Property Name="customerEmailAddress" Type="Edm.String"/>
22902+
<Property Name="customerName" Type="Edm.String"/>
22903+
<Property Name="customerNotes" Type="Edm.String"/>
22904+
<Property Name="customerPhone" Type="Edm.String"/>
2289022905
<Property Name="customers" Type="Collection(graph.bookingCustomerInformationBase)" Nullable="false"/>
2289122906
<Property Name="customerTimeZone" Type="Edm.String"/>
2289222907
<Property Name="duration" Type="Edm.Duration" Nullable="false"/>
@@ -22974,6 +22989,7 @@
2297422989
<Property Name="displayName" Type="Edm.String" Nullable="false"/>
2297522990
<Property Name="emailAddress" Type="Edm.String"/>
2297622991
<Property Name="isEmailNotificationEnabled" Type="Edm.Boolean" Nullable="false"/>
22992+
<Property Name="membershipStatus" Type="graph.bookingStaffMembershipStatus" Nullable="false"/>
2297722993
<Property Name="role" Type="graph.bookingStaffRole" Nullable="false"/>
2297822994
<Property Name="timeZone" Type="Edm.String"/>
2297922995
<Property Name="useBusinessHours" Type="Edm.Boolean" Nullable="false"/>

office365/sharepoint/activities/action_facet.py

+11
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
from office365.sharepoint.activities.facets.get_comment import GetCommentFacet
1010
from office365.sharepoint.activities.facets.get_mention import GetMentionFacet
1111
from office365.sharepoint.activities.facets.move import MoveFacet
12+
from office365.sharepoint.activities.facets.point_in_time_restore import (
13+
PointInTimeRestoreFacet,
14+
)
1215
from office365.sharepoint.activities.facets.rename import RenameFacet
1316
from office365.sharepoint.activities.facets.sharing import SharingFacet
17+
from office365.sharepoint.activities.facets.task_completed import TaskCompletedFacet
18+
from office365.sharepoint.activities.facets.version import VersionFacet
1419

1520

1621
class ActionFacet(ClientValue):
@@ -26,8 +31,11 @@ def __init__(
2631
edit=EditFacet(),
2732
mention=GetMentionFacet(),
2833
move=MoveFacet(),
34+
pointInTimeRestore=PointInTimeRestoreFacet(),
2935
rename=RenameFacet(),
3036
share=SharingFacet(),
37+
taskCompleted=TaskCompletedFacet(),
38+
version=VersionFacet(),
3139
):
3240
"""
3341
:param AddToOneDriveFacet add_to_one_drive:
@@ -48,8 +56,11 @@ def __init__(
4856
self.edit = edit
4957
self.mention = mention
5058
self.move = move
59+
self.pointInTimeRestore = pointInTimeRestore
5160
self.rename = rename
5261
self.share = share
62+
self.taskCompleted = taskCompleted
63+
self.version = version
5364

5465
def __repr__(self):
5566
return self.facet_type
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
from office365.runtime.client_value import ClientValue
2+
from office365.sharepoint.activities.facets.revision_set import RevisionSetFacet
23

34

45
class ActivityClientRequest(ClientValue):
6+
def __init__(self, revisionSet=RevisionSetFacet()):
7+
self.revisionSet = revisionSet
8+
59
@property
610
def entity_type_name(self):
711
return "Microsoft.SharePoint.Activities.ActivityClientRequest"

office365/sharepoint/activities/client_response.py

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
class ActivityClientResponse(ClientValue):
55
""""""
66

7+
def __init__(self, id_, message=None, serverId=None, status=None):
8+
# type: (str, str, str, int) -> None
9+
""" """
10+
self.id = id_
11+
self.message = message
12+
self.serverId = serverId
13+
self.status = status
14+
715
@property
816
def entity_type_name(self):
917
return "Microsoft.SharePoint.Activities.ActivityClientResponse"

office365/sharepoint/activities/facets/delete.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class DeleteFacet(ClientValue):
55
""""""
66

77
def __init__(self, name=None):
8+
# type: (str) -> None
89
self.name = name
910

1011
@property

office365/sharepoint/activities/facets/in_doc.py

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
class InDocFacet(ClientValue):
55
""""""
66

7+
def __init__(self, contentId=None, navigationId=None):
8+
self.contentId = contentId
9+
self.navigationId = navigationId
10+
711
@property
812
def entity_type_name(self):
913
return "Microsoft.SharePoint.Activities.InDocFacet"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class PointInTimeRestoreFacet(ClientValue):
5+
""""""
6+
7+
@property
8+
def entity_type_name(self):
9+
return "Microsoft.SharePoint.Activities.PointInTimeRestoreFacet"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class RevisionSetFacet(ClientValue):
5+
""" """
6+
7+
@property
8+
def entity_type_name(self):
9+
return "Microsoft.SharePoint.Activities.RevisionSetFacet"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class TaskCompletedFacet(ClientValue):
5+
""" """
6+
7+
@property
8+
def entity_type_name(self):
9+
return "Microsoft.SharePoint.Activities.TaskCompletedFacet"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class VersionFacet(ClientValue):
5+
""""""
6+
7+
def __init__(self, fromVersion=None):
8+
self.fromVersion = fromVersion
9+
10+
@property
11+
def entity_type_name(self):
12+
return "Microsoft.SharePoint.Activities.VersionFacet"

office365/sharepoint/entity.py

+15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from office365.runtime.auth.client_credential import ClientCredential
66
from office365.runtime.auth.user_credential import UserCredential
77
from office365.runtime.client_object import ClientObject
8+
from office365.runtime.paths.v3.entity import EntityPath
89
from office365.runtime.queries.delete_entity import DeleteEntityQuery
910
from office365.runtime.queries.update_entity import UpdateEntityQuery
1011

@@ -53,3 +54,17 @@ def entity_type_name(self):
5354
@property
5455
def property_ref_name(self):
5556
return "Id"
57+
58+
def set_property(self, name, value, persist_changes=True):
59+
super(Entity, self).set_property(name, value, persist_changes)
60+
if name == self.property_ref_name:
61+
if self.resource_path is None:
62+
if self.parent_collection:
63+
self._resource_path = EntityPath(
64+
value, self.parent_collection.resource_path
65+
)
66+
else:
67+
pass
68+
else:
69+
self._resource_path.patch(value)
70+
return self

office365/sharepoint/folders/folder.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,8 @@ def server_relative_path(self):
571571

572572
@property
573573
def property_ref_name(self):
574-
# type: () -> str
575-
return "ServerRelativeUrl"
574+
# type: () -> Optional[str]
575+
return None
576576

577577
def get_property(self, name, default_value=None):
578578
if default_value is None:
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
from office365.runtime.queries.service_operation import ServiceOperationQuery
12
from office365.sharepoint.entity import Entity
23

34

45
class SiteVersionPolicyManager(Entity):
56
""""""
7+
8+
def set_auto_expiration(self):
9+
""""""
10+
qry = ServiceOperationQuery(self, "SetAutoExpiration")
11+
self.context.add_query(qry)
12+
return self

office365/sharepoint/tenant/management/externalusers/results/get.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Optional
2+
13
from office365.runtime.paths.resource_path import ResourcePath
24
from office365.sharepoint.entity import Entity
35
from office365.sharepoint.tenant.management.externalusers.collection import (
@@ -8,10 +10,12 @@
810
class GetExternalUsersResults(Entity):
911
@property
1012
def total_user_count(self):
13+
# type: () -> Optional[int]
1114
return self.properties.get("TotalUserCount", None)
1215

1316
@property
1417
def user_collection_position(self):
18+
# type: () -> Optional[int]
1519
return self.properties.get("UserCollectionPosition", None)
1620

1721
@property

office365/sharepoint/tenant/management/office365_tenant.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Optional
2+
13
from office365.runtime.client_object_collection import ClientObjectCollection
24
from office365.runtime.client_result import ClientResult
35
from office365.runtime.client_value_collection import ClientValueCollection
@@ -29,8 +31,19 @@ def __init__(self, context):
2931
)
3032
super(Office365Tenant, self).__init__(context, static_path)
3133

34+
@property
35+
def addressbar_link_permission(self):
36+
# type: () -> Optional[int]
37+
return self.properties.get("AddressbarLinkPermission", None)
38+
39+
@property
40+
def allow_comments_text_on_email_enabled(self):
41+
# type: () -> Optional[bool]
42+
return self.properties.get("AllowCommentsTextOnEmailEnabled", None)
43+
3244
@property
3345
def allow_editing(self):
46+
# type: () -> Optional[bool]
3447
return self.properties.get("AllowEditing", None)
3548

3649
@property
@@ -62,6 +75,7 @@ def add_tenant_cdn_origin(self, cdn_type, origin_url):
6275

6376
def disable_sharing_for_non_owners_of_site(self, site_url):
6477
"""
78+
Disables Sharing For Non Owners
6579
:param str site_url:
6680
"""
6781
payload = {"siteUrl": site_url}

office365/sharepoint/userprofiles/people_manager.py

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def get_properties_for(self, user_or_name):
173173
return_type = PersonProperties(self.context)
174174

175175
def _get_properties_for_inner(account_name):
176+
# type: (str) -> None
176177
params = {"accountName": account_name}
177178
qry = ServiceOperationQuery(
178179
self, "GetPropertiesFor", params, None, None, return_type

0 commit comments

Comments
 (0)