Skip to content

Commit cfe036e

Browse files
vvgrem@gmail.comvvgrem@gmail.com
authored andcommitted
SharePoint API: PeopleManager methods
1 parent cc1f0bf commit cfe036e

File tree

5 files changed

+53
-3
lines changed

5 files changed

+53
-3
lines changed

office365/sharepoint/userprofiles/peopleManager.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from office365.runtime.queries.service_operation_query import ServiceOperationQuery
33
from office365.runtime.resource_path import ResourcePath
44
from office365.sharepoint.base_entity import BaseEntity
5+
from office365.sharepoint.userprofiles.personProperties import PersonProperties
6+
from office365.sharepoint.userprofiles.personPropertiesCollection import PersonPropertiesCollection
57
from office365.sharepoint.userprofiles.personalSiteCreationPriority import PersonalSiteCreationPriority
68

79

@@ -22,6 +24,17 @@ def get_user_profile_properties(self, accountName):
2224
self.context.add_query(qry)
2325
return result
2426

27+
def get_properties_for(self, accountName):
28+
"""
29+
:type accountName: str
30+
:return: PersonProperties
31+
"""
32+
result = PersonProperties(self.context)
33+
payload = {"accountName": accountName}
34+
qry = ServiceOperationQuery(self, "GetPropertiesFor", payload, None, None, result)
35+
self.context.add_query(qry)
36+
return result
37+
2538
def get_default_document_library(self, accountName, createSiteIfNotExists=False,
2639
siteCreationPriority=PersonalSiteCreationPriority.Low):
2740
result = ClientResult(str)
@@ -31,3 +44,15 @@ def get_default_document_library(self, accountName, createSiteIfNotExists=False,
3144
qry = ServiceOperationQuery(self, "GetDefaultDocumentLibrary", params, None, None, result)
3245
self.context.add_query(qry)
3346
return result
47+
48+
def get_people_followed_by(self, accountName):
49+
"""
50+
51+
:type accountName: str
52+
:return: PersonPropertiesCollection
53+
"""
54+
result = PersonPropertiesCollection(self.context)
55+
params = {"accountName": accountName}
56+
qry = ServiceOperationQuery(self, "GetPeopleFollowedBy", params, None, None, result)
57+
self.context.add_query(qry)
58+
return result
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from office365.sharepoint.base_entity import BaseEntity
2+
3+
4+
class PersonProperties(BaseEntity):
5+
pass
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from office365.runtime.client_object_collection import ClientObjectCollection
2+
from office365.sharepoint.userprofiles.personProperties import PersonProperties
3+
4+
5+
class PersonPropertiesCollection(ClientObjectCollection):
6+
7+
def __init__(self, context, resource_path=None):
8+
super(PersonPropertiesCollection, self).__init__(context, PersonProperties, resource_path)

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
requests~=2.24.0
22
requests_ntlm [NTLMAuthentication]
33
setuptools~=50.3.2
4+
msal~=1.5.1
45

5-
msal~=1.5.0
6-
astunparse~=1.6.3

tests/sharepoint/test_user_profile.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,22 @@ def test4_get_user_props(self):
3838
self.my_client.execute_query()
3939
self.assertIsNotNone(result.value)
4040

41-
def test5_get_default_document_library(self):
41+
def test5_get_properties_for(self):
42+
me = self.my_client.web.currentUser.get().execute_query()
43+
people_manager = PeopleManager(self.my_client)
44+
result = people_manager.get_properties_for(me.login_name)
45+
self.my_client.execute_query()
46+
self.assertIsNotNone(result)
47+
48+
def test6_get_default_document_library(self):
4249
me = self.my_client.web.currentUser.get().execute_query()
4350
people_manager = PeopleManager(self.my_client)
4451
result = people_manager.get_default_document_library(me.login_name)
4552
self.my_client.execute_query()
4653
self.assertIsNotNone(result.value)
54+
55+
def test7_get_people_followed_by(self):
56+
me = self.my_client.web.currentUser.get().execute_query()
57+
people_manager = PeopleManager(self.my_client)
58+
result = people_manager.get_people_followed_by(me.login_name).execute_query()
59+
self.assertIsNotNone(result)

0 commit comments

Comments
 (0)