Skip to content

Commit

Permalink
Model updates for OneDrive API
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed Apr 3, 2024
1 parent 7e954f7 commit 86b2dd8
Show file tree
Hide file tree
Showing 25 changed files with 280 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/sharepoint/lists/clear.py
@@ -1,5 +1,5 @@
"""
This example deletes a SharePoint all the list items.
This example deletes all the list items in a list.
"""
from office365.sharepoint.client_context import ClientContext
from tests import test_client_credentials, test_team_site_url
Expand Down
2 changes: 1 addition & 1 deletion examples/sharepoint/sites/get_basic_props.py
Expand Up @@ -2,7 +2,7 @@
Gets site basic properties
"""
from office365.sharepoint.client_context import ClientContext
from tests import test_client_credentials, test_site_url, test_team_site_url
from tests import test_client_credentials, test_team_site_url

client = ClientContext(test_team_site_url).with_credentials(test_client_credentials)
site = client.site.get().execute_query()
Expand Down
2 changes: 1 addition & 1 deletion examples/sharepoint/webs/get_props.py
Expand Up @@ -11,4 +11,4 @@

client = ClientContext(test_site_url).with_credentials(test_client_credentials)
web = client.web.get().expand(["Author"]).execute_query()
print(web.author.user_principal_name)
print(web.author)
17 changes: 14 additions & 3 deletions office365/communications/onlinemeetings/online_meeting.py
Expand Up @@ -4,6 +4,8 @@
from office365.communications.onlinemeetings.participants import MeetingParticipants
from office365.entity import Entity
from office365.outlook.mail.item_body import ItemBody
from office365.runtime.client_result import ClientResult
from office365.runtime.queries.function import FunctionQuery
from office365.runtime.types.collections import StringCollection


Expand All @@ -13,6 +15,17 @@ class OnlineMeeting(Entity):
the attendees list, and the description.
"""

def get_virtual_appointment_join_web_url(self):
"""Get a join web URL for a Microsoft Virtual Appointment. This web URL includes enhanced
business-to-customer experiences such as mobile browser join and virtual lobby rooms.
With Teams Premium, you can configure a custom lobby room experience for attendees by adding your company
logo and access the Virtual Appointments usage report for organizational analytics.
"""
return_type = ClientResult(self.context, str())
qry = FunctionQuery(self, "getVirtualAppointmentJoinWebUrl", None, return_type)
self.context.add_query(qry)
return return_type

@property
def allow_attendee_to_enable_camera(self):
# type: () -> Optional[bool]
Expand Down Expand Up @@ -74,9 +87,7 @@ def start_datetime(self):
@start_datetime.setter
def start_datetime(self, value):
# type: (datetime) -> None
"""
Sets the meeting start time in UTC.
"""
"""Sets the meeting start time in UTC."""
self.set_property("startDateTime", value.isoformat())

@property
Expand Down
12 changes: 12 additions & 0 deletions office365/onedrive/driveitems/driveItem.py
Expand Up @@ -22,6 +22,7 @@
from office365.onedrive.driveitems.photo import Photo
from office365.onedrive.driveitems.publication_facet import PublicationFacet
from office365.onedrive.driveitems.remote_item import RemoteItem
from office365.onedrive.driveitems.retention_label import ItemRetentionLabel
from office365.onedrive.driveitems.special_folder import SpecialFolder
from office365.onedrive.driveitems.thumbnail_set import ThumbnailSet
from office365.onedrive.driveitems.uploadable_properties import (
Expand Down Expand Up @@ -785,6 +786,17 @@ def permissions(self):
),
)

@property
def retention_label(self):
# type: () -> ItemRetentionLabel
"""Information about retention label and settings enforced on the driveItem."""
return self.properties.get(
"retentionLabel",
ItemRetentionLabel(
self.context, ResourcePath("retentionLabel", self.resource_path)
),
)

@property
def publication(self):
# type: () -> PublicationFacet
Expand Down
25 changes: 25 additions & 0 deletions office365/onedrive/driveitems/retention_label.py
@@ -0,0 +1,25 @@
from typing import Optional

from office365.directory.permissions.identity_set import IdentitySet
from office365.entity import Entity


class ItemRetentionLabel(Entity):
"""
Groups retention and compliance-related properties on an item into a single structure.
Currently, supported only for driveItem.
"""

@property
def is_label_applied_explicitly(self):
# type: () -> Optional[bool]
"""Specifies whether the label is applied explicitly on the item.
True indicates that the label is applied explicitly; otherwise, the label is inherited from its parent.
Read-only."""
return self.properties.get("isLabelAppliedExplicitly", None)

@property
def label_applied_by(self):
# type: () -> Optional[IdentitySet]
"""Identity of the user who applied the label. Read-only."""
return self.properties.get("labelAppliedBy", IdentitySet())
13 changes: 13 additions & 0 deletions office365/onedrive/workbooks/charts/chart.py
Expand Up @@ -2,11 +2,24 @@
from office365.onedrive.workbooks.charts.axes import WorkbookChartAxes
from office365.onedrive.workbooks.charts.data_labels import WorkbookChartDataLabels
from office365.runtime.paths.resource_path import ResourcePath
from office365.runtime.queries.service_operation import ServiceOperationQuery


class WorkbookChart(Entity):
"""Represents a chart object in a workbook."""

def set_position(self, startCell, endCell):
"""Positions the chart relative to cells on the worksheet.
:param str startCell: The start cell. It is where the chart is moved to. The start cell is the top-left or
top-right cell, depending on the user's right-to-left display settings.
:param str endCell: The end cell. If specified, the chart's width and height is set to fully cover up
this cell/range.
"""
payload = {"startCell": startCell, "endCell": endCell}
qry = ServiceOperationQuery(self, "setPosition", None, payload)
self.context.add_query(qry)
return self

@property
def axes(self):
"""Represents chart axes."""
Expand Down
5 changes: 5 additions & 0 deletions office365/onedrive/workbooks/icon.py
@@ -0,0 +1,5 @@
from office365.runtime.client_value import ClientValue


class WorkbookIcon(ClientValue):
"""Represents a cell icon."""
6 changes: 6 additions & 0 deletions office365/onedrive/workbooks/names/named_item.py
Expand Up @@ -33,6 +33,12 @@ def comment(self):
"""Represents the comment associated with this name."""
return self.properties.get("comment", None)

@property
def scope(self):
# type: () -> Optional[str]
"""Indicates whether the name is scoped to the workbook or to a specific worksheet."""
return self.properties.get("scope", None)

@property
def worksheet(self):
"""Returns the worksheet on which the named item is scoped to. Available only if the item is scoped
Expand Down
5 changes: 5 additions & 0 deletions office365/onedrive/workbooks/ranges/font.py
@@ -0,0 +1,5 @@
from office365.entity import Entity


class WorkbookRangeFont(Entity):
"""This object represents the font attributes (font name, font size, color, etc.) for an object."""
60 changes: 60 additions & 0 deletions office365/onedrive/workbooks/ranges/format.py
@@ -1,5 +1,10 @@
from typing import Optional

from office365.entity import Entity
from office365.entity_collection import EntityCollection
from office365.onedrive.workbooks.ranges.border import WorkbookRangeBorder
from office365.onedrive.workbooks.ranges.fill import WorkbookRangeFill
from office365.onedrive.workbooks.ranges.font import WorkbookRangeFont
from office365.onedrive.workbooks.ranges.format_protection import (
WorkbookFormatProtection,
)
Expand All @@ -9,6 +14,53 @@
class WorkbookRangeFormat(Entity):
"""A format object encapsulating the range's font, fill, borders, alignment, and other properties."""

@property
def column_width(self):
# type: () -> Optional[float]
"""Gets or sets the width of all columns within the range. If the column widths aren't uniform,
null will be returned."""
return self.properties.get("columnWidth", None)

@property
def horizontal_alignment(self):
# type: () -> Optional[str]
"""Represents the horizontal alignment for the specified object"""
return self.properties.get("horizontalAlignment", None)

@property
def row_height(self):
# type: () -> Optional[float]
"""Gets or sets the height of all rows in the range. If the row heights aren't uniform null will be returned."""
return self.properties.get("rowHeight", None)

@property
def vertical_alignment(self):
# type: () -> Optional[str]
"""Represents the vertical alignment for the specified object.
Possible values are: Top, Center, Bottom, Justify, Distributed."""
return self.properties.get("verticalAlignment", None)

@property
def wrap_text(self):
# type: () -> Optional[bool]
"""Indicates if Excel wraps the text in the object.
A null value indicates that the entire range doesn't have uniform wrap setting
"""
return self.properties.get("wrapText", None)

@property
def borders(self):
# type: () -> EntityCollection[WorkbookRangeBorder]
"""Collection of border objects that apply to the overall range selected."""
return self.properties.get(
"borders",
EntityCollection(
self.context,
WorkbookRangeBorder,
ResourcePath("borders", self.resource_path),
),
)

@property
def fill(self):
"""Returns the fill object defined on the overall range"""
Expand All @@ -17,6 +69,14 @@ def fill(self):
WorkbookRangeFill(self.context, ResourcePath("fill", self.resource_path)),
)

@property
def font(self):
"""Returns the font object defined on the overall range selected"""
return self.properties.get(
"font",
WorkbookRangeFont(self.context, ResourcePath("font", self.resource_path)),
)

@property
def protection(self):
"""Returns the format protection object for a range"""
Expand Down
12 changes: 12 additions & 0 deletions office365/onedrive/workbooks/ranges/range.py
Expand Up @@ -82,6 +82,18 @@ def column_count(self):
"""Represents the total number of columns in the range. Read-only."""
return self.properties.get("columnCount", None)

@property
def column_hidden(self):
# type: () -> Optional[bool]
"""Represents if all columns of the current range are hidden."""
return self.properties.get("columnHidden", None)

@property
def column_index(self):
# type: () -> Optional[int]
"""Represents the column number of the first cell in the range. Zero-indexed. Read-only."""
return self.properties.get("columnIndex", None)

@property
def format(self):
"""Returns a format object, encapsulating the range's font, fill, borders, alignment, and other properties"""
Expand Down
6 changes: 6 additions & 0 deletions office365/onedrive/workbooks/ranges/reference.py
Expand Up @@ -3,3 +3,9 @@

class WorkbookRangeReference(ClientValue):
""""""

def __init__(self, address=None):
"""
:param str address:
"""
self.address = address
26 changes: 26 additions & 0 deletions office365/onedrive/workbooks/sort_field.py
@@ -0,0 +1,26 @@
from office365.onedrive.workbooks.icon import WorkbookIcon
from office365.runtime.client_value import ClientValue


class WorkbookSortField(ClientValue):
"""Represents a condition in a sorting operation."""

def __init__(
self, ascending=None, color=None, dataOption=None, icon=WorkbookIcon(), key=None
):
"""
:param bool ascending: Represents whether the sorting is done in an ascending fashion.
:param str color: Represents the color that is the target of the condition if the sorting is on font
or cell color.
:param str dataOption: Represents additional sorting options for this field.
Possible values are: Normal, TextAsNumber.
:param WorkbookIcon icon: Represents the icon that is the target of the condition if the sorting
is on the cell's icon.
:param str key: Represents the column (or row, depending on the sort orientation) that the condition is on.
Represented as an offset from the first column (or row).
"""
self.ascending = ascending
self.color = color
self.dataOption = dataOption
self.icon = icon
self.key = key
16 changes: 16 additions & 0 deletions office365/onedrive/workbooks/tables/pivot_table_collection.py
@@ -0,0 +1,16 @@
from office365.entity_collection import EntityCollection
from office365.onedrive.workbooks.tables.pivot_table import WorkbookPivotTable
from office365.runtime.queries.service_operation import ServiceOperationQuery


class WorkbookPivotTableCollection(EntityCollection[WorkbookPivotTable]):
def __init__(self, context, resource_path=None):
super(WorkbookPivotTableCollection, self).__init__(
context, WorkbookPivotTable, resource_path
)

def refresh_all(self):
"""Refreshes the PivotTable."""
qry = ServiceOperationQuery(self, "refreshAll")
self.context.add_query(qry)
return self
3 changes: 3 additions & 0 deletions office365/onedrive/workbooks/worksheets/protection_options.py
Expand Up @@ -7,6 +7,9 @@ class WorkbookWorksheetProtectionOptions(ClientValue):
def __init__(
self, allowAutoFilter=None, allowDeleteColumns=None, allowDeleteRows=None
):
"""
:param bool allowAutoFilter:
"""
self.allowAutoFilter = allowAutoFilter
self.allowDeleteColumns = allowDeleteColumns
self.allowDeleteRows = allowDeleteRows
9 changes: 5 additions & 4 deletions office365/onedrive/workbooks/worksheets/worksheet.py
Expand Up @@ -6,7 +6,9 @@
from office365.onedrive.workbooks.names.named_item import WorkbookNamedItem
from office365.onedrive.workbooks.ranges.range import WorkbookRange
from office365.onedrive.workbooks.tables.collection import WorkbookTableCollection
from office365.onedrive.workbooks.tables.pivot_table import WorkbookPivotTable
from office365.onedrive.workbooks.tables.pivot_table_collection import (
WorkbookPivotTableCollection,
)
from office365.onedrive.workbooks.worksheets.protection import (
WorkbookWorksheetProtection,
)
Expand Down Expand Up @@ -94,13 +96,12 @@ def tables(self):

@property
def pivot_tables(self):
# type: () -> EntityCollection[WorkbookPivotTable]
# type: () -> WorkbookPivotTableCollection
"""Collection of PivotTables that are part of the worksheet."""
return self.properties.get(
"pivotTables",
EntityCollection(
WorkbookPivotTableCollection(
self.context,
WorkbookPivotTable,
ResourcePath("pivotTables", self.resource_path),
),
)
Expand Down
2 changes: 1 addition & 1 deletion office365/sharepoint/comments/collection.py
Expand Up @@ -4,7 +4,7 @@
from office365.sharepoint.entity_collection import EntityCollection


class CommentCollection(EntityCollection):
class CommentCollection(EntityCollection[Comment]):
def __init__(self, context, resource_path=None):
super(CommentCollection, self).__init__(context, Comment, resource_path)

Expand Down
2 changes: 2 additions & 0 deletions office365/sharepoint/features/collection.py
Expand Up @@ -11,6 +11,7 @@ def __init__(self, context, resource_path=None, parent=None):
super(FeatureCollection, self).__init__(context, Feature, resource_path, parent)

def add(self, feature_id, force, featdef_scope, verify_if_activated=False):
# type: (str, bool, int, bool) -> Feature
"""
Adds the feature to the collection of activated features and returns the added feature.
Expand Down Expand Up @@ -43,6 +44,7 @@ def _create_if_not_activated(f):
return return_type

def get_by_id(self, feature_id):
# type: (str) -> Feature
"""Returns the feature for the given feature identifier. Returns NULL if no feature is available for the given
feature identifier.
Expand Down
2 changes: 2 additions & 0 deletions office365/sharepoint/permissions/securable_object.py
Expand Up @@ -162,6 +162,7 @@ def has_unique_role_assignments(self):

@property
def first_unique_ancestor_securable_object(self):
# type: () -> SecurableObject
"""Specifies the object where role assignments for this object are defined"""
return self.properties.get(
"FirstUniqueAncestorSecurableObject",
Expand All @@ -173,6 +174,7 @@ def first_unique_ancestor_securable_object(self):

@property
def role_assignments(self):
# type: () -> RoleAssignmentCollection
"""The role assignments for the securable object."""
return self.properties.get(
"RoleAssignments",
Expand Down

0 comments on commit 86b2dd8

Please sign in to comment.