Skip to content

Commit 3f096c9

Browse files
vvgrem@gmail.comvvgrem@gmail.com
authored andcommitted
SharePoint API: navigation, web namespace methods & types
1 parent 73b53cb commit 3f096c9

File tree

16 files changed

+230
-16
lines changed

16 files changed

+230
-16
lines changed

generator/metadata/SharePoint.xml

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

office365/runtime/client_object.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def get_property(self, name):
7575

7676
def set_property(self, name, value, persist_changes=True):
7777
"""Sets Property value
78+
7879
:param str name: Property name
7980
:param any value: Property value
8081
:param bool persist_changes: Persist changes
@@ -95,6 +96,7 @@ def set_property(self, name, value, persist_changes=True):
9596
self._properties[name] = value
9697
else:
9798
self._properties[name] = value
99+
return self
98100

99101
def to_json(self):
100102
return dict((k, v) for k, v in self.properties.items() if k in self._changed_properties)
@@ -106,9 +108,7 @@ def ensure_property(self, name, action):
106108
:type action: () -> None
107109
:type name: str
108110
"""
109-
names_to_include = [name]
110-
self.ensure_properties(names_to_include, action)
111-
return self
111+
return self.ensure_properties([name], action)
112112

113113
def ensure_properties(self, names, action):
114114
"""
@@ -127,6 +127,7 @@ def _process_query(current_query):
127127
self.context.after_execute_query(_process_query)
128128
else:
129129
action()
130+
return self
130131

131132
def clone_object(self):
132133
result = copy.deepcopy(self)
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 MicroServiceManager(BaseEntity):
5+
pass

office365/sharepoint/navigation/__init__.py

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class MenuState(ClientValue):
5+
pass
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from office365.runtime.client_result import ClientResult
2+
from office365.runtime.queries.service_operation_query import ServiceOperationQuery
3+
from office365.runtime.resource_path import ResourcePath
4+
from office365.sharepoint.base_entity import BaseEntity
5+
from office365.sharepoint.navigation.menuState import MenuState
6+
7+
8+
class NavigationService(BaseEntity):
9+
10+
def __init__(self, context):
11+
"""The entry point for REST-based navigation service operations."""
12+
super().__init__(context, ResourcePath("Microsoft.SharePoint.Navigation.REST.NavigationServiceRest"))
13+
14+
def get_publishing_navigation_provider_type(self, mapProviderName="SPNavigationProvider"):
15+
"""
16+
Gets a publishing navigation provider type when publishing feature is turned on for the site (2).
17+
If navigation provider is not found on the site MUST return InvalidSiteMapProvider type.
18+
19+
:param str mapProviderName: The server will use "SPNavigationProvider" as provider name
20+
if mapProviderName is not specified.
21+
:return:
22+
"""
23+
result = ClientResult(None)
24+
params = {"mapProviderName": mapProviderName}
25+
qry = ServiceOperationQuery(self, "GetPublishingNavigationProviderType", params, None, None, result)
26+
self.context.add_query(qry)
27+
return result
28+
29+
def global_nav(self):
30+
return_type = MenuState()
31+
qry = ServiceOperationQuery(self, "GlobalNav", None, None, None, return_type)
32+
self.context.add_query(qry)
33+
return return_type
34+
35+
def menu_node_key(self, currentUrl):
36+
pass
37+
38+
def save_menu_state(self):
39+
pass
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class PublishingNavigationProviderType:
2+
def __init__(self):
3+
pass
4+
5+
InvalidSiteMapProvider = 0
6+
PortalSiteMapProvider = 1
7+
TaxonomySiteMapProvider = 2

office365/sharepoint/portal/SPSiteManager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ def delete(self, site_id):
2727
return self
2828

2929
def get_status(self, site_url):
30-
"""Get the status of a SharePoint site"""
30+
"""Get the status of a SharePoint site
31+
32+
:type site_url: str
33+
"""
3134
response = SPSiteCreationResponse()
3235
qry = ServiceOperationQuery(self, "Status", None, {'url': site_url}, None, response)
3336
self.context.add_query(qry)

office365/sharepoint/principal/group_collection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ def get_by_id(self, group_id):
2525
return group
2626

2727
def get_by_name(self, group_name):
28-
"""Returns a cross-site group from the collection based on the name of the group."""
28+
"""Returns a cross-site group from the collection based on the name of the group.
29+
30+
:type group_name: str
31+
"""
2932
return Group(self.context,
30-
ResourcePathServiceOperation("getbyname", [group_name], self.resource_path))
33+
ResourcePathServiceOperation("getByName", [group_name], self.resource_path))
3134

3235
def remove_by_id(self, group_id):
3336
"""Removes the group with the specified member ID from the collection."""

office365/sharepoint/sites/site.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
from office365.sharepoint.lists.list import List
88
from office365.sharepoint.principal.user import User
99
from office365.sharepoint.recyclebin.recycleBinItemCollection import RecycleBinItemCollection
10+
from office365.sharepoint.sites.sph_site import SPHSite
1011
from office365.sharepoint.webs.web import Web
12+
from office365.sharepoint.webs.web_template_collection import WebTemplateCollection
1113

1214

1315
class Site(ClientObject):
@@ -16,6 +18,22 @@ class Site(ClientObject):
1618
def __init__(self, context):
1719
super(Site, self).__init__(context, ResourcePath("Site", None))
1820

21+
def is_valid_home_site(self):
22+
result = ClientResult(None)
23+
24+
def _site_loaded():
25+
SPHSite.is_valid_home_site(self.context, self.url, result)
26+
self.ensure_property("Url", _site_loaded)
27+
return result
28+
29+
def set_as_home_site(self):
30+
result = ClientResult(None)
31+
32+
def _site_loaded():
33+
self.result = SPHSite.set_as_home_site(self.context, self.url, result)
34+
self.ensure_property("Url", _site_loaded)
35+
return result
36+
1937
def get_changes(self, query):
2038
"""Returns the collection of all changes from the change log that have occurred within the scope of the site,
2139
based on the specified query.
@@ -37,6 +55,28 @@ def get_recycle_bin_items(self, pagingInfo=None, rowLimit=100, isAscending=True,
3755
self.context.add_query(qry)
3856
return result
3957

58+
def get_web_templates(self, lcid=1033, override_compat_level=0):
59+
"""
60+
Returns the collection of site definitions that are available for creating
61+
Web sites within the site collection.<99>
62+
63+
:param int lcid: A 32-bit unsigned integer that specifies the language of the site definitions that are
64+
returned from the site collection.
65+
:param int override_compat_level: Specifies the compatibility level of the site (2)
66+
to return from the site collection. If this value is 0, the compatibility level of the site (2) is used.
67+
:return:
68+
"""
69+
params = {
70+
"LCID": lcid,
71+
"overrideCompatLevel": override_compat_level
72+
}
73+
return_type = WebTemplateCollection(self.context,
74+
ResourcePathServiceOperation("GetWebTemplates", params, self.resource_path))
75+
76+
qry = ServiceOperationQuery(self, "GetWebTemplates", params, None, None, return_type)
77+
self.context.add_query(qry)
78+
return return_type
79+
4080
@staticmethod
4181
def get_url_by_id(context, site_id, stop_redirect=False):
4282
"""Gets Site Url By Id
@@ -54,6 +94,10 @@ def get_url_by_id(context, site_id, stop_redirect=False):
5494
context.add_query(qry)
5595
return result
5696

97+
@staticmethod
98+
def get_url_by_id_for_web(context):
99+
pass
100+
57101
@staticmethod
58102
def exists(context, url):
59103
"""Determine whether site exists
@@ -91,6 +135,10 @@ def owner(self):
91135
else:
92136
return User(self.context, ResourcePath("owner", self.resource_path))
93137

138+
@property
139+
def url(self):
140+
return self.properties.get('Url', None)
141+
94142
@property
95143
def recycleBin(self):
96144
"""Get recycle bin"""

0 commit comments

Comments
 (0)