Skip to content

Commit

Permalink
SharePoint API types updates in files, folders, web & view namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed Sep 11, 2023
1 parent 50866f6 commit bdee6a0
Show file tree
Hide file tree
Showing 55 changed files with 981 additions and 145 deletions.
1 change: 1 addition & 0 deletions examples/sharepoint/files/download_recent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ctx = ClientContext(test_site_url).with_credentials(test_user_credentials)
lib_title = "Documents"
lib = ctx.web.lists.get_by_title(lib_title)

recent_items = lib.items.order_by("Created desc").select(["ID", "FileRef"]).top(1).get().execute_query()
for item in recent_items: # type: ListItem
file_url = item.properties.get("FileRef")
Expand Down
8 changes: 8 additions & 0 deletions examples/sharepoint/lists/filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.lists.list import List
from tests import test_client_credentials, test_team_site_url

ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)
result = ctx.web.lists.get().select(["IsSystemList", "Title"]).filter("IsSystemList eq true").execute_query()
for lst in result: # type: List
print(lst.title)
2 changes: 1 addition & 1 deletion examples/sharepoint/sites/get_basic_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
print("Site url: {}".format(site.url))

result = site.is_valid_home_site().execute_query()
print("Landing Intranet site: {}".format(result.value))
print("Is home site: {}".format(result.value))
18 changes: 8 additions & 10 deletions office365/runtime/odata/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class ODataType(object):

primitive_types = {
bool: "Edm.Boolean",
int: "Edm.Int32",
Expand Down Expand Up @@ -61,17 +60,16 @@ def try_parse_datetime(value):
:param str value: Represents date and time with values ranging from 12:00:00 midnight, January 1, 1753 A.D.
through 11:59:59 P.M, December 9999 A.D.
"""
known_formats = ["%Y-%m-%dT%H:%M:%SZ", "%Y-%m-%dT%H:%M:%S.%fZ", "%Y-%m-%dT%H:%M:%S", "%Y-%m-%dT%H:%M:%S.%f"]

try:
return datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%SZ")
except ValueError:
result = None
for cur_format in known_formats:
try:
return datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%fZ")
except ValueError as e:
try:
return datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%S")
except ValueError as e:
return None
result = datetime.datetime.strptime(value, cur_format)
break
except ValueError:
pass
return result

@staticmethod
def resolve_type(client_type):
Expand Down
1 change: 0 additions & 1 deletion office365/sharepoint/changes/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class ChangeAlert(Change):
@property
def alert_id(self):
"""Identifies the changed alert.
:rtype: str or None
"""
return self.properties.get("AlertId", None)
55 changes: 44 additions & 11 deletions office365/sharepoint/contenttypes/content_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class ContentType(BaseEntity):
def reorder_fields(self, field_names):
"""
The ReorderFields method is called to change the order in which fields appear in a content type.
:param list[str] field_names: Rearranges the collection of fields in the order in which field internal
names are specified.
"""
Expand All @@ -35,7 +34,6 @@ def update(self, update_children):
"""
Updates the content type, and any child objects of the content type if specified,
with any changes made to the content type.
:param bool update_children: Specifies whether changes propagate to child objects of the content type.
"""
super(ContentType, self).update()
Expand Down Expand Up @@ -74,13 +72,15 @@ def display_form_template_name(self):
"""
Specifies the name of a custom display form template to use for list items that have been assigned
the content type.
:rtype: str or None
"""
return self.properties.get("DisplayFormTemplateName", None)

@property
def display_form_url(self):
"""
Specifies the URL of a custom display form to use for list items that have been assigned the content type.
:rtype: str or None
"""
return self.properties.get("DisplayFormUrl", None)

Expand All @@ -89,7 +89,7 @@ def edit_form_client_side_component_id(self):
"""
The component properties of an SPFx Form Customizer to connect to this content type for usage with edit item
forms
:rtype: str
:rtype: str or None
"""
return self.properties.get("EditFormClientSideComponentId", None)

Expand All @@ -103,11 +103,18 @@ def edit_form_client_side_component_properties(self):

@property
def id(self):
"""Specifies an identifier for the content type as specified in [MS-WSSTS] section 2.1.2.8.1.
:rtype: ContentTypeId
"""
Specifies an identifier for the content type as specified in [MS-WSSTS] section 2.1.2.8.1.
"""
return self.properties.get("Id", ContentTypeId())

@property
def sealed(self):
"""Specifies whether the content type can be changed.
:rtype: bool or None
"""
return self.properties.get('Sealed', None)

@property
def string_id(self):
"""A string representation of the value of the Id
Expand Down Expand Up @@ -158,19 +165,42 @@ def description_resource(self):
return self.properties.get('DescriptionResource',
UserResource(self.context, ResourcePath("DescriptionResource", self.resource_path)))

@property
def document_template(self):
"""
Specifies the file path to the document template (1) used for a new list item that has been assigned
the content type.
:rtype: str or None
"""
return self.properties.get("DocumentTemplate", None)

@property
def document_template_url(self):
"""
Specifies the URL of the document template assigned to the content type.
:rtype: str or None
"""
return self.properties.get("DocumentTemplateUrl", None)

@property
def edit_form_url(self):
"""
Specifies the URL of a custom edit form to use for list items that have been assigned the content type.
:rtype: str or None
"""
return self.properties.get("EditFormUrl", None)

@property
def group(self):
"""Gets the group of the content type.
:rtype: str or None
"""
return self.properties.get("Group", None)

@group.setter
def group(self, value):
"""Sets the group of the content type.
:type value: str
:type value: str or None
"""
self.set_property("Group", value)

Expand All @@ -181,12 +211,16 @@ def hidden(self):

@property
def js_link(self):
"""Gets or sets the JSLink for the content type custom form template"""
"""Gets or sets the JSLink for the content type custom form template
:rtype: str or None
"""
return self.properties.get("JSLink", None)

@property
def read_only(self):
"""Specifies whether changes to the content type properties are denied."""
"""Specifies whether changes to the content type properties are denied.
:rtype: bool or None
"""
return self.properties.get("ReadOnly", None)

@property
Expand All @@ -198,7 +232,6 @@ def name_resource(self):
@property
def schema_xml(self):
"""Specifies the XML schema that represents the content type.
:rtype: str or None
"""
return self.properties.get("SchemaXml", None)
Expand Down
18 changes: 11 additions & 7 deletions office365/sharepoint/contenttypes/fieldlinks/field_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ class FieldLink(BaseEntity):
def id(self):
"""
Gets a value that specifies the GUID of the FieldLink.
:rtype: str or None
"""
return self.properties.get('Id', None)

@property
def field_internal_name(self):
"""Gets a value that specifies field internal name
:rtype: str or None
"""
return self.properties.get('FieldInternalName', None)
Expand All @@ -28,20 +26,26 @@ def read_only(self):
"""
return self.properties.get('ReadOnly', None)

@property
def hidden(self):
"""
Gets a value that specifies whether the field is displayed in forms that can be edited.
:rtype: bool or None
"""
return self.properties.get('Hidden', None)

@property
def required(self):
"""
Gets a value that specifies whether the field (2) requires a value.
:rtype: bool or None
"""
return self.properties.get('Required', None)

@property
def hidden(self):
def show_in_display_form(self):
"""
Gets a value that specifies whether the field is displayed in forms that can be edited.
A Boolean value that indicates whether this field is shown in the display form.
:rtype: bool or None
"""
return self.properties.get('Hidden', None)
return self.properties.get('ShowInDisplayForm', None)
1 change: 0 additions & 1 deletion office365/sharepoint/files/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def upload(self, path_or_file):
Note: This method only supports files up to 4MB in size!
Consider create_upload_session method instead for larger files
:param str or typing.IO path_or_file: path where file to upload resides or file handle
"""
if hasattr(path_or_file, 'read'):
Expand Down
Loading

0 comments on commit bdee6a0

Please sign in to comment.