diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..c6b933b02 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,6 @@ +# Treat each other well + +Everyone participating in the _Office365-REST-Python-Client_ project, and in particular in the issue tracker, +pull requests, and social media activity, is expected to treat other people with respect +and more generally to follow the guidelines articulated in the +[Python Community Code of Conduct](https://www.python.org/psf/codeofconduct/). diff --git a/office365/onedrive/driveitems/driveItem.py b/office365/onedrive/driveitems/driveItem.py index 9402bce70..4e902f691 100644 --- a/office365/onedrive/driveitems/driveItem.py +++ b/office365/onedrive/driveitems/driveItem.py @@ -66,6 +66,7 @@ class DriveItem(BaseItem): OneDrive and SharePoint are returned as driveItem resources""" def get_files(self, recursive=False, page_size=None): + # type: (bool, Optional[int]) -> EntityCollection["DriveItem"] """Retrieves files :param bool recursive: Determines whether to enumerate folders recursively :param int page_size: Page size @@ -94,6 +95,7 @@ def _after_loaded(col): return return_type def get_folders(self, recursive=False, page_size=None): + # type: (bool, Optional[int]) -> EntityCollection["DriveItem"] """Retrieves folders :param bool recursive: Determines whether to enumerate folders recursively :param int page_size: Page size @@ -177,6 +179,16 @@ def create_link( self.context.add_query(qry) return return_type + def discard_checkout(self): + """Discard the check out of a driveItem. This action releases a driveItem resource that was previously + checked out. Any changes made to the item while it was checked out are discarded. + + The same user that performed the checkout must discard it. Another alternative is to use application permissions + """ + qry = ServiceOperationQuery(self, "discardCheckout") + self.context.add_query(qry) + return self + def extract_sensitivity_labels(self): # type: () -> ClientResult[ExtractSensitivityLabelsResult] """ diff --git a/office365/onedrive/sitepages/canvas_layout.py b/office365/onedrive/sitepages/canvas_layout.py index a4d0b4312..7aef5da97 100644 --- a/office365/onedrive/sitepages/canvas_layout.py +++ b/office365/onedrive/sitepages/canvas_layout.py @@ -1,7 +1,7 @@ from office365.entity import Entity from office365.entity_collection import EntityCollection -from office365.onedrive.sitepages.horizontal_section import HorizontalSection -from office365.onedrive.sitepages.vertical_section import VerticalSection +from office365.onedrive.sitepages.sections.horizontal import HorizontalSection +from office365.onedrive.sitepages.sections.vertical import VerticalSection from office365.runtime.paths.resource_path import ResourcePath diff --git a/office365/onedrive/sitepages/sections/__init__.py b/office365/onedrive/sitepages/sections/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/office365/onedrive/sitepages/horizontal_section.py b/office365/onedrive/sitepages/sections/horizontal.py similarity index 90% rename from office365/onedrive/sitepages/horizontal_section.py rename to office365/onedrive/sitepages/sections/horizontal.py index d794d33c9..af54411a1 100644 --- a/office365/onedrive/sitepages/horizontal_section.py +++ b/office365/onedrive/sitepages/sections/horizontal.py @@ -1,6 +1,6 @@ from office365.entity import Entity from office365.entity_collection import EntityCollection -from office365.onedrive.sitepages.horizontal_section_column import ( +from office365.onedrive.sitepages.sections.horizontal_column import ( HorizontalSectionColumn, ) from office365.runtime.paths.resource_path import ResourcePath diff --git a/office365/onedrive/sitepages/horizontal_section_column.py b/office365/onedrive/sitepages/sections/horizontal_column.py similarity index 100% rename from office365/onedrive/sitepages/horizontal_section_column.py rename to office365/onedrive/sitepages/sections/horizontal_column.py diff --git a/office365/onedrive/sitepages/vertical_section.py b/office365/onedrive/sitepages/sections/vertical.py similarity index 100% rename from office365/onedrive/sitepages/vertical_section.py rename to office365/onedrive/sitepages/sections/vertical.py diff --git a/office365/onedrive/sitepages/webparts/position.py b/office365/onedrive/sitepages/webparts/position.py new file mode 100644 index 000000000..62e4c133e --- /dev/null +++ b/office365/onedrive/sitepages/webparts/position.py @@ -0,0 +1,5 @@ +from office365.runtime.client_value import ClientValue + + +class WebPartPosition(ClientValue): + """Represents the position information of the given web part to the current page""" diff --git a/office365/onedrive/sitepages/webparts/web_part.py b/office365/onedrive/sitepages/webparts/web_part.py index 3b19bdc08..edb3a33ca 100644 --- a/office365/onedrive/sitepages/webparts/web_part.py +++ b/office365/onedrive/sitepages/webparts/web_part.py @@ -1,5 +1,17 @@ from office365.entity import Entity +from office365.onedrive.sitepages.webparts.position import WebPartPosition +from office365.runtime.client_result import ClientResult +from office365.runtime.queries.service_operation import ServiceOperationQuery class WebPart(Entity): """Represents a specific web part instance on a SharePoint page.""" + + def get_position_of_web_part(self): + """Returns the position of the specified web part in the page.""" + return_type = ClientResult(self.context, WebPartPosition()) + qry = ServiceOperationQuery( + self, "getPositionOfWebPart", return_type=return_type + ) + self.context.add_query(qry) + return self