Skip to content

Commit 92cc6ed

Browse files
vvgrem@gmail.comvvgrem@gmail.com
authored andcommitted
SharePoint API: permissions and sharing namespaces changes
1 parent 99a9757 commit 92cc6ed

35 files changed

+552
-15
lines changed

examples/sharepoint/connect_with_user_creds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from office365.runtime.auth.userCredential import UserCredential
44
from office365.sharepoint.client_context import ClientContext
55

6-
ctx = ClientContext.connect_with_credentials("https://mediadev8.sharepoint.com/sites/team/",
6+
ctx = ClientContext.connect_with_credentials(settings["url"],
77
UserCredential(settings['user_credentials']['username'],
88
settings['user_credentials']['password']))
99

generator/metadata/SharePoint.xml

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

office365/runtime/clientValue.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ class ClientValue(object):
44
containing entity or as a temporary value
55
"""
66

7-
def __init__(self):
7+
def __init__(self, namespace=None):
88
super(ClientValue, self).__init__()
9+
self._namespace = namespace
910

1011
def set_property(self, k, v, persist_changes=True):
1112
if hasattr(self, k):
@@ -26,7 +27,9 @@ def to_json(self):
2627

2728
@property
2829
def entity_type_name(self):
29-
return None
30+
if self._namespace:
31+
return ".".join([self._namespace, type(self).__name__])
32+
return type(self).__name__
3033

3134
@property
3235
def is_server_object_null(self):

office365/runtime/clientValueCollection.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,26 @@ def __iter__(self):
1818
def to_json(self):
1919
return self._data
2020

21+
def set_property(self, index, value, persist_changes=False):
22+
child_value = self._item_type
23+
if isinstance(child_value, ClientValue):
24+
for k, v in value.items():
25+
child_value.set_property(k, v, False)
26+
else:
27+
child_value = value
28+
self.add(child_value)
29+
2130
@property
2231
def entity_type_name(self):
23-
edm_primitive_types = {
24-
int: "Edm.Int32",
25-
str: "Edm.String",
32+
primitive_types = {
33+
"bool": "Edm.Boolean",
34+
"int": "Edm.Int32",
35+
"str": "Edm.String",
2636
}
27-
item_type_name = edm_primitive_types.get(self._item_type, "Edm.Int32")
37+
item_type_name = type(self._item_type).__name__
38+
is_primitive = primitive_types.get(item_type_name, None) is not None
39+
if is_primitive:
40+
item_type_name = primitive_types[item_type_name]
41+
elif isinstance(self._item_type, ClientValue):
42+
item_type_name = self._item_type.entity_type_name
2843
return "Collection({0})".format(item_type_name)

office365/sharepoint/forms/form.py

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 Form(BaseEntity):
5+
"""A form provides a display and editing interface for a single list item."""
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from office365.runtime.client_object_collection import ClientObjectCollection
2+
3+
4+
class FormCollection(ClientObjectCollection):
5+
6+
def get_by_page_type(self):
7+
pass
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from office365.runtime.client_object_collection import ClientObjectCollection
2+
3+
4+
class RoleAssignmentCollection(ClientObjectCollection):
5+
"""Represents a collection of RoleAssignment resources."""
6+
7+
def remove_role_assignment(self, principal_id, role_def_id):
8+
"""Removes the role assignment with the specified principal and role definition from the collection.
9+
10+
:param int role_def_id: The ID of the role definition in the role assignment.
11+
:param int principal_id: The ID of the user or group in the role assignment.
12+
"""
13+
pass
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from office365.sharepoint.base_entity import BaseEntity
2+
3+
4+
class RoleDefinition(BaseEntity):
5+
"""Defines a single role definition, including a name, description, and set of rights."""
6+
7+
@property
8+
def name(self):
9+
"""Gets a value that specifies the role definition name."""
10+
return self.properties.get('Name', None)
11+
12+
@name.setter
13+
def name(self, value):
14+
"""Sets a value that specifies the role definition name."""
15+
self.set_property('Name', value)
16+
17+
@property
18+
def description(self):
19+
"""Gets or sets a value that specifies the description of the role definition."""
20+
return self.properties.get('Description', None)
21+
22+
@description.setter
23+
def description(self, value):
24+
"""Gets or sets a value that specifies the description of the role definition."""
25+
self.set_property('Description', value)
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.permissions.roleDefinition import RoleDefinition
3+
4+
5+
class RoleDefinitionCollection(ClientObjectCollection):
6+
7+
def __init__(self, context, resource_path=None):
8+
super(RoleDefinitionCollection, self).__init__(context, RoleDefinition, resource_path)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from office365.runtime.clientValue import ClientValue
2+
from office365.sharepoint.permissions.basePermissions import BasePermissions
3+
4+
5+
class RoleDefinitionCreationInformation(ClientValue):
6+
7+
def __init__(self):
8+
"""Contains properties that are used as parameters to initialize a role definition."""
9+
super(RoleDefinitionCreationInformation, self).__init__()
10+
self.Name = None
11+
self.Description = None
12+
self.BasePermissions = BasePermissions()

0 commit comments

Comments
 (0)