Skip to content

Commit 3af062c

Browse files
committed
SharePoint API: sharing namespace enhancements
1 parent 43b287a commit 3af062c

21 files changed

+201
-34
lines changed

office365/runtime/client_result.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def __init__(self, context, default_value=None):
66
Client result
77
88
:type context: office365.runtime.client_runtime_context.ClientRuntimeContext
9-
:type default_value: int or str or bool or dict or office365.runtime.client_value.ClientValue
9+
:type default_value: int or str or bytes or bool or dict or office365.runtime.client_value.ClientValue
1010
"""
1111
self._context = context
1212
self._value = default_value

office365/sharepoint/fields/calculated.py

+4
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ class FieldCalculated(Field):
1212
@property
1313
def currency_locale_id(self):
1414
"""
15+
Gets the locale ID that is used for currency on the Web site.
16+
1517
:rtype: int or None
1618
"""
1719
return self.properties.get('CurrencyLocaleId', None)
1820

1921
@property
2022
def formula(self):
2123
"""
24+
Specifies the formula for the field
25+
2226
:rtype: str or None
2327
"""
2428
return self.properties.get('Formula', None)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class SharingAbilityStatus(ClientValue):
5+
"""Represents the status for a specific sharing capability for the current user."""
6+
7+
def __init__(self, disabled_reason=None, enabled=None):
8+
"""
9+
:param str disabled_reason: Indicates the reason why the capability is disabled if the capability is disabled
10+
for any reason.
11+
:param bool enabled: Indicates whether capability is enabled.
12+
"""
13+
self.disabledReason = disabled_reason
14+
self.enabled = enabled
15+
16+
@property
17+
def entity_type_name(self):
18+
return "SP.Sharing.SharingAbilityStatus"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from office365.runtime.client_value import ClientValue
2+
from office365.sharepoint.sharing.ability_status import SharingAbilityStatus
3+
4+
5+
class SharingLinkAbilities(ClientValue):
6+
"""
7+
Represents the set of capabilities for specific configurations of tokenized sharing link for the current user
8+
and whether they are enabled or not.
9+
"""
10+
11+
def __init__(self, can_add_new_external_principals=SharingAbilityStatus(),
12+
can_delete_edit_link=SharingAbilityStatus(),
13+
can_delete_manage_list_link=SharingAbilityStatus()):
14+
"""
15+
:param SharingAbilityStatus can_add_new_external_principals:
16+
:param SharingAbilityStatus can_delete_edit_link:
17+
"""
18+
self.canAddNewExternalPrincipals = can_add_new_external_principals
19+
self.canDeleteEditLink = can_delete_edit_link
20+
self.canDeleteManageListLink = can_delete_manage_list_link
21+
22+
@property
23+
def entity_type_name(self):
24+
return "SP.Sharing.SharingLinkAbilities"

office365/sharepoint/sharing/permission_information.py

+30-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,33 @@ class SharingPermissionInformation(BaseEntity):
55
"""
66
Contains information about a sharing permission entity such as group or role.
77
"""
8-
pass
8+
9+
@property
10+
def is_default_permission(self):
11+
"""
12+
Identifies whether or not the permission entity is a default SP.Group or role (meaning it is recommended
13+
for granting permissions).
14+
15+
A value of true specifies the current permission is a default SP.Group for granting permissions to a site
16+
(site owner, member, or visitor SP.Group) or a default role for granting permission to a file or other
17+
non-site object (edit or view). A value of false specifies otherwise.
18+
19+
For SPSites & SPWebs, there can be three default permission entities: owners, members, or visitors SPGroups.
20+
For granting permissions to a file or other non-site object, there can be two default permission entities:
21+
a role for view permissions (StandardViewerRoleDefinitionID) and a role for edit permissions
22+
(StandardEditorRoleDefinitionID).
23+
24+
:rtype: bool or None
25+
"""
26+
return self.properties.get("IsDefaultPermission", None)
27+
28+
@property
29+
def permission_id(self):
30+
"""Gets the ID of this permission in the following formats: group:x, role: xxxxxx.
31+
:rtype: str or None
32+
"""
33+
return self.properties.get("PermissionId", None)
34+
35+
@property
36+
def entity_type_name(self):
37+
return "SP.SharingPermissionInformation"
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1+
from office365.runtime.queries.service_operation import ServiceOperationQuery
12
from office365.sharepoint.base_entity import BaseEntity
23

34

45
class PersonalWeb(BaseEntity):
56
"""Microsoft.SharePoint.Client.Sharing.PersonalWeb namespace represents methods that apply to a Web site for
67
individual users. Methods act on the users default document library."""
78

9+
@staticmethod
10+
def fix_permission_inheritance(context):
11+
"""
12+
This method fixes the permission inheritance for the default document library of the personal web when
13+
breakRoleInheritance didn't happen correctly during the default document library creation.
14+
15+
:param office365.sharepoint.client_context.ClientContext context: SharePoint client context
16+
"""
17+
binding_type = PersonalWeb(context)
18+
qry = ServiceOperationQuery(binding_type, "FixPermissionInheritance", None, None, None, None, True)
19+
context.add_query(qry)
20+
return binding_type
21+
822
@property
923
def entity_type_name(self):
1024
return "SP.Sharing.PersonalWeb"

office365/sharepoint/sharing/web_sharing_manager.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
class WebSharingManager(BaseEntity):
5+
"""Specifies a placeholder for all web sharing methods."""
56

67
@property
78
def entity_type_name(self):

office365/sharepoint/tenant/administration/settings_service.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self, context):
1313
super(TenantAdminSettingsService, self).__init__(context, static_path)
1414

1515
def get_tenant_sharing_status(self):
16-
return_type = ClientResult(self.context)
16+
return_type = ClientResult(self.context, int())
1717
qry = ServiceOperationQuery(self, "GetTenantSharingStatus", None, None, None, return_type)
1818
self.context.add_query(qry)
1919
return return_type

office365/sharepoint/tenant/administration/site_properties_collection.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from office365.runtime.queries.service_operation import ServiceOperationQuery
33
from office365.sharepoint.base_entity_collection import BaseEntityCollection
44
from office365.sharepoint.tenant.administration.site_properties import SiteProperties
5+
from office365.sharepoint.tenant.administration.site_state_properties import SiteStateProperties
56

67

78
class SitePropertiesCollection(BaseEntityCollection):
@@ -22,16 +23,25 @@ def get_lock_state_by_id(self, site_id):
2223
"""
2324
:param str site_id: Site identifier
2425
"""
25-
result = ClientResult(self.context)
26-
qry = ServiceOperationQuery(self, "GetLockStateById", [site_id], None, None, result)
26+
return_type = ClientResult(self.context, int())
27+
qry = ServiceOperationQuery(self, "GetLockStateById", [site_id], None, None, return_type)
2728
self.context.add_query(qry)
28-
return result
29+
return return_type
30+
31+
def get_site_state_properties(self, site_id):
32+
"""
33+
:param str site_id: Site identifier
34+
"""
35+
return_type = ClientResult(self.context, SiteStateProperties())
36+
qry = ServiceOperationQuery(self, "GetSiteStateProperties", [site_id], None, None, return_type)
37+
self.context.add_query(qry)
38+
return return_type
2939

3040
def check_site_is_archived_by_id(self, site_id):
3141
"""
3242
:param str site_id: Site identifier
3343
"""
34-
result = ClientResult(self.context)
35-
qry = ServiceOperationQuery(self, "CheckSiteIsArchivedById", [site_id], None, None, result)
44+
return_type = ClientResult(self.context, bool())
45+
qry = ServiceOperationQuery(self, "CheckSiteIsArchivedById", [site_id], None, None, return_type)
3646
self.context.add_query(qry)
37-
return result
47+
return return_type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class SiteStateProperties(ClientValue):
5+
6+
@property
7+
def entity_type_name(self):
8+
return "Microsoft.Online.SharePoint.TenantAdministration.SiteStateProperties"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class SiteUserGroupInfo(ClientValue):
5+
6+
@property
7+
def entity_type_name(self):
8+
return "Microsoft.Online.SharePoint.TenantAdministration.SiteUserGroupInfo"

office365/sharepoint/tenant/administration/tenant.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def remove_home_site(self):
124124

125125
def has_valid_education_license(self):
126126
""""""
127-
return_type = ClientResult(self.context)
127+
return_type = ClientResult(self.context, bool())
128128
qry = ServiceOperationQuery(self, "HasValidEducationLicense", None, None, None, return_type)
129129
self.context.add_query(qry)
130130
return return_type
@@ -133,17 +133,17 @@ def export_to_csv(self, view_xml=None):
133133
"""
134134
:param str view_xml:
135135
"""
136-
result = ClientResult(self.context)
136+
return_type = ClientResult(self.context)
137137
payload = {
138138
"viewXml": view_xml
139139
}
140-
qry = ServiceOperationQuery(self, "ExportToCSV", None, payload, None, result)
140+
qry = ServiceOperationQuery(self, "ExportToCSV", None, payload, None, return_type)
141141
self.context.add_query(qry)
142-
return result
142+
return return_type
143143

144144
def render_policy_report(self):
145145
""""""
146-
return_type = ClientResult(self.context)
146+
return_type = ClientResult(self.context, bytes())
147147
payload = {
148148
"parameters": RenderListDataParameters(),
149149
"overrideParameters": RenderListDataOverrideParameters()
@@ -354,10 +354,10 @@ def restore_deleted_site(self, site_url):
354354
355355
:param str site_url: A string representing the URL of the site.
356356
"""
357-
result = SpoOperation(self.context)
358-
qry = ServiceOperationQuery(self, "RestoreDeletedSite", [site_url], None, None, result)
357+
return_type = SpoOperation(self.context)
358+
qry = ServiceOperationQuery(self, "RestoreDeletedSite", [site_url], None, None, return_type)
359359
self.context.add_query(qry)
360-
return result
360+
return return_type
361361

362362
def get_site_properties_by_url(self, url, include_detail=False):
363363
"""
@@ -410,7 +410,7 @@ def send_email(self, site_url):
410410
"""
411411
:type site_url: str
412412
"""
413-
return_type = ClientResult(self.context)
413+
return_type = ClientResult(self.context, bool())
414414
payload = {"siteUrl": site_url}
415415
qry = ServiceOperationQuery(self, "SendEmail", None, payload, None, return_type)
416416
self.context.add_query(qry)

office365/sharepoint/tenant/management/externalusers/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from office365.runtime.paths.service_operation import ServiceOperationPath
2+
from office365.sharepoint.base_entity_collection import BaseEntityCollection
3+
from office365.sharepoint.tenant.management.externalusers.external_user import ExternalUser
4+
5+
6+
class ExternalUserCollection(BaseEntityCollection):
7+
8+
def __init__(self, context, resource_path=None):
9+
super(ExternalUserCollection, self).__init__(context, ExternalUser, resource_path)
10+
11+
def get_by_id(self, unique_id):
12+
"""
13+
:param str unique_id: The Id of the external user.
14+
"""
15+
return ExternalUser(self.context, ServiceOperationPath("GetById", [unique_id], self.resource_path))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from office365.sharepoint.base_entity import BaseEntity
2+
3+
4+
class ExternalUser(BaseEntity):
5+
6+
@property
7+
def entity_type_name(self):
8+
return "Microsoft.Online.SharePoint.TenantManagement.ExternalUser"

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

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from office365.runtime.paths.resource_path import ResourcePath
2+
from office365.sharepoint.base_entity import BaseEntity
3+
from office365.sharepoint.tenant.management.externalusers.collection import ExternalUserCollection
4+
5+
6+
class GetExternalUsersResults(BaseEntity):
7+
8+
@property
9+
def total_user_count(self):
10+
return self.properties.get("TotalUserCount", None)
11+
12+
@property
13+
def user_collection_position(self):
14+
return self.properties.get("UserCollectionPosition", None)
15+
16+
@property
17+
def external_user_collection(self):
18+
return self.properties.get("ExternalUserCollection",
19+
ExternalUserCollection(self.context, ResourcePath("ExternalUserCollection")))
20+
21+
@property
22+
def entity_type_name(self):
23+
return "Microsoft.Online.SharePoint.TenantManagement.GetExternalUsersResults"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from office365.sharepoint.base_entity import BaseEntity
2+
3+
4+
class RemoveExternalUsersResults(BaseEntity):
5+
6+
@property
7+
def entity_type_name(self):
8+
return "Microsoft.Online.SharePoint.TenantManagement.RemoveExternalUsersResults"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from office365.sharepoint.base_entity import BaseEntity
2+
3+
4+
class SPOUserSessionRevocationResult(BaseEntity):
5+
6+
@property
7+
def entity_type_name(self):
8+
return "Microsoft.Online.SharePoint.TenantManagement.SPOUserSessionRevocationResult"
9+
10+

office365/sharepoint/tenant/management/office365_tenant.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
from office365.sharepoint.base_entity import BaseEntity
77
from office365.sharepoint.principal.user import User
88
from office365.sharepoint.tenant.administration.siteinfo_for_site_picker import SiteInfoForSitePicker
9-
from office365.sharepoint.tenant.management.users_results import GetExternalUsersResults, RemoveExternalUsersResults, \
10-
SPOUserSessionRevocationResult
9+
from office365.sharepoint.tenant.management.externalusers.results.session_revocation import SPOUserSessionRevocationResult
10+
from office365.sharepoint.tenant.management.externalusers.results.remove import RemoveExternalUsersResults
11+
from office365.sharepoint.tenant.management.externalusers.results.get import GetExternalUsersResults
1112
from office365.sharepoint.tenant.administration.theme_properties import ThemeProperties
1213

1314

office365/sharepoint/tenant/management/users_results.py

-14
This file was deleted.

0 commit comments

Comments
 (0)