Skip to content

Commit eccc660

Browse files
committed
workbook namespace new types
1 parent a42face commit eccc660

File tree

14 files changed

+414
-13
lines changed

14 files changed

+414
-13
lines changed

examples/onedrive/files/get_permissions.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
file_path = "Archive/Financial Sample.xlsx"
1414
file_item = client.me.drive.root.get_by_path(file_path)
1515
permissions = file_item.permissions.get().execute_query()
16-
print(permissions)
16+
for perm in permissions:
17+
print(perm.granted_to_v2)

generator/metadata/SharePoint.xml

+219
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
from office365.entity import Entity
2+
from office365.onedrive.workbooks.charts.title_format import WorkbookChartTitleFormat
3+
from office365.runtime.paths.resource_path import ResourcePath
24

35

46
class WorkbookChartTitle(Entity):
57
"""Represents a chart title object of a chart."""
8+
9+
@property
10+
def format(self):
11+
""" The formatting of a chart title, which includes fill and font formatting."""
12+
return self.properties.get(
13+
"format",
14+
WorkbookChartTitleFormat(
15+
self.context, ResourcePath("format", self.resource_path)
16+
),
17+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from office365.entity import Entity
2+
3+
4+
class WorkbookChartTitleFormat(Entity):
5+
"""Represents a chart title object of a chart."""
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
1+
from typing import Optional
2+
13
from office365.entity import Entity
24

35

46
class WorkbookRangeBorder(Entity):
57
"""Represents the border of an object."""
8+
9+
@property
10+
def color(self):
11+
# type: () -> Optional[str]
12+
"""The HTML color code that represents the color of the border line. Can either be of the form #RRGGBB,
13+
for example "FFA500", or a named HTML color, for example orange."""
14+
return self.properties.get("color", None)
15+
16+
@property
17+
def side_index(self):
18+
# type: () -> Optional[str]
19+
"""Indicates the specific side of the border.
20+
The possible values are: EdgeTop, EdgeBottom, EdgeLeft, EdgeRight, InsideVertical, InsideHorizontal,
21+
DiagonalDown, DiagonalUp. Read-only."""
22+
return self.properties.get("sideIndex", None)
23+
24+
@property
25+
def style(self):
26+
# type: () -> Optional[str]
27+
"""Indicates the line style for the border. The possible values are: None, Continuous, Dash, DashDot,
28+
DashDotDot, Dot, Double, SlantDashDot."""
29+
return self.properties.get("style", None)
30+
31+
@property
32+
def weight(self):
33+
# type: () -> Optional[str]
34+
"""The weight of the border around a range. The possible values are: Hairline, Thin, Medium, Thick."""
35+
return self.properties.get("weight", None)

office365/onedrive/workbooks/ranges/range.py

+6
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ def column_index(self):
120120
"""Represents the column number of the first cell in the range. Zero-indexed. Read-only."""
121121
return self.properties.get("columnIndex", None)
122122

123+
@property
124+
def row_index(self):
125+
# type: () -> Optional[int]
126+
"""Returns the row number of the first cell in the range. Zero-indexed. Read-only."""
127+
return self.properties.get("rowIndex", None)
128+
123129
@property
124130
def format(self):
125131
"""Returns a format object, encapsulating the range's font, fill, borders, alignment, and other properties"""

office365/onedrive/workbooks/worksheets/protection_options.py

+34-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,40 @@ class WorkbookWorksheetProtectionOptions(ClientValue):
55
"""Represents the protection of a sheet object."""
66

77
def __init__(
8-
self, allowAutoFilter=None, allowDeleteColumns=None, allowDeleteRows=None
8+
self,
9+
allow_auto_filter=None,
10+
allow_delete_columns=None,
11+
allow_delete_rows=None,
12+
allow_format_cells=None,
13+
allow_format_columns=None,
14+
allow_format_rows=None,
15+
allow_insert_columns=None,
16+
allow_insert_hyperlinks=None,
17+
allow_insert_rows=None,
18+
allow_pivot_tables=None,
19+
allow_sort=None,
920
):
1021
"""
11-
:param bool allowAutoFilter:
22+
:param bool allow_auto_filter: Represents the worksheet protection option of allowing using auto filter feature.
23+
:param bool allow_delete_columns: Represents the worksheet protection option of allowing deleting columns.
24+
:param bool allow_delete_rows: Represents the worksheet protection option of allowing deleting rows.
25+
:param bool allow_format_cells: Represents the worksheet protection option of allowing formatting cells.
26+
:param bool allow_format_columns: Represents the worksheet protection option of allowing formatting columns.
27+
:param bool allow_format_rows: Represents the worksheet protection option of allowing formatting rows.
28+
:param bool allow_insert_columns: Represents the worksheet protection option of allowing inserting columns.
29+
:param bool allow_insert_hyperlinks: Represents the worksheet protection option of allowing inserting hyperlinks.
30+
:param bool allow_insert_rows: Represents the worksheet protection option of allowing inserting rows.
31+
:param bool allow_pivot_tables: Represents the worksheet protection option of allowing using pivot table feature.
32+
:param bool allow_sort: Represents the worksheet protection option of allowing sorting.
1233
"""
13-
self.allowAutoFilter = allowAutoFilter
14-
self.allowDeleteColumns = allowDeleteColumns
15-
self.allowDeleteRows = allowDeleteRows
34+
self.allowAutoFilter = allow_auto_filter
35+
self.allowDeleteColumns = allow_delete_columns
36+
self.allowDeleteRows = allow_delete_rows
37+
self.allowFormatCells = allow_format_cells
38+
self.allowFormatColumns = allow_format_columns
39+
self.allowFormatRows = allow_format_rows
40+
self.allowInsertColumns = allow_insert_columns
41+
self.allowInsertHyperlinks = allow_insert_hyperlinks
42+
self.allowInsertRows = allow_insert_rows
43+
self.allowPivotTables = allow_pivot_tables
44+
self.allowSort = allow_sort

office365/outlook/calendar/events/event.py

+57
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ def dismiss_reminder(self):
7878
self.context.add_query(qry)
7979
return self
8080

81+
def permanent_delete(self):
82+
"""
83+
Permanently delete an event and place it in the purges folder in the dumpster in the user's mailbox.
84+
Email clients such as outlook or outlook on the web can't access permanently deleted items.
85+
Unless there's a hold set on the mailbox, the items are permanently deleted after a set period of time.
86+
"""
87+
qry = ServiceOperationQuery(self, "permanentDelete")
88+
self.context.add_query(qry)
89+
return self
90+
8191
@property
8292
def allow_new_time_proposals(self):
8393
# type: () -> Optional[bool]
@@ -126,6 +136,53 @@ def is_all_day(self):
126136
"""
127137
return self.properties.get("isAllDay", None)
128138

139+
@property
140+
def is_cancelled(self):
141+
# type: () -> Optional[bool]
142+
"""
143+
Set to true if the event has been canceled.
144+
"""
145+
return self.properties.get("isCancelled", None)
146+
147+
@property
148+
def is_draft(self):
149+
# type: () -> Optional[bool]
150+
"""
151+
Set to true if the user has updated the meeting in Outlook but hasn't sent the updates to attendees.
152+
Set to false if all changes are sent, or if the event is an appointment without any attendees.
153+
"""
154+
return self.properties.get("isDraft", None)
155+
156+
@property
157+
def is_online_meeting(self):
158+
# type: () -> Optional[bool]
159+
"""
160+
True if this event has online meeting information
161+
(that is, onlineMeeting points to an onlineMeetingInfo resource), false otherwise.
162+
Default is false (onlineMeeting is null). Optional.
163+
After you set isOnlineMeeting to true, Microsoft Graph initializes onlineMeeting.
164+
Subsequently, Outlook ignores any further changes to isOnlineMeeting, and the meeting remains available online.
165+
"""
166+
return self.properties.get("isOnlineMeeting", None)
167+
168+
@property
169+
def is_organizer(self):
170+
# type: () -> Optional[bool]
171+
"""
172+
Set to true if the calendar owner (specified by the owner property of the calendar) is the organizer of
173+
the event (specified by the organizer property of the event). It also applies if a delegate organized the
174+
event on behalf of the owner.
175+
"""
176+
return self.properties.get("isOrganizer", None)
177+
178+
@property
179+
def is_reminder_on(self):
180+
# type: () -> Optional[bool]
181+
"""
182+
Set to true if an alert is set to remind the user of the event.
183+
"""
184+
return self.properties.get("isReminderOn", None)
185+
129186
@property
130187
def start(self):
131188
"""The date, time, and time zone that the event starts. By default, the start time is in UTC."""

office365/runtime/odata/json_format.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
class ODataJsonFormat(object):
55
"""OData JSON format"""
66

7-
def __init__(self, metadata_level=None, etag=None):
8-
# type: (str, str) -> None
7+
def __init__(self, metadata_level=None):
8+
# type: (str) -> None
99
self.metadata_level = metadata_level
10-
self.etag = etag
1110

1211
__metaclass__ = ABCMeta
1312

@@ -23,6 +22,18 @@ def collection(self):
2322
def collection_next(self):
2423
raise NotImplementedError
2524

25+
@property
26+
def collection_delta(self):
27+
raise NotImplementedError
28+
29+
@property
30+
def etag(self):
31+
raise NotImplementedError
32+
33+
@property
34+
def value_tag(self):
35+
raise NotImplementedError
36+
2637
@property
2738
def media_type(self):
2839
# type: () -> str

office365/runtime/odata/request.py

-2
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,3 @@ def _ensure_http_headers(self, request):
155155
media_type = self.json_format.media_type
156156
request.ensure_header("Content-Type", media_type)
157157
request.ensure_header("Accept", media_type)
158-
if self.json_format.etag is not None:
159-
request.ensure_header("If-Match", self.json_format.etag)

office365/runtime/odata/v3/json_light_format.py

+14
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,24 @@ def collection_next(self):
2525
"""Property name for a reference to the next page of results"""
2626
return "__next"
2727

28+
@property
29+
def collection_delta(self):
30+
"""Property name for a reference to the next page of results"""
31+
return "__delta"
32+
2833
@property
2934
def metadata_type(self):
3035
return "__metadata"
3136

37+
@property
38+
def value_tag(self):
39+
return "__value"
40+
41+
@property
42+
def etag(self):
43+
"""The entity tag that represents the version of the object."""
44+
return "__etag"
45+
3246
@property
3347
def media_type(self):
3448
return "application/json;odata={0}".format(self.metadata_level)

office365/runtime/odata/v4/json_format.py

+19
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,35 @@ def __init__(self, metadata_level=ODataV4MetadataLevel.Minimal):
1414

1515
@property
1616
def metadata_type(self):
17+
"""The OData entity type in Microsoft Graph that describes the represented object."""
1718
return "@odata.type"
1819

20+
@property
21+
def value_tag(self):
22+
"""The OData entity type in Microsoft Graph that describes the represented object."""
23+
return "@odata.value"
24+
1925
@property
2026
def collection(self):
2127
return "value"
2228

2329
@property
2430
def collection_next(self):
31+
"""
32+
Property name for a reference to the next page of results
33+
"""
2534
return "@odata.nextLink"
2635

36+
@property
37+
def collection_delta(self):
38+
""" """
39+
return "@odata.deltaLink"
40+
41+
@property
42+
def etag(self):
43+
"""The entity tag that represents the version of the object."""
44+
return "@odata.etag"
45+
2746
@property
2847
def media_type(self):
2948
return "application/json;odata.metadata={0};odata.streaming={1};IEEE754Compatible={2}".format(

tests/onedrive/test_drive.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ def test7_list_changes(self):
4949
result = self.client.me.drive.root.delta.get().execute_query()
5050
self.assertIsNotNone(result.resource_path)
5151

52-
#def test8_get_delta_link(self):
52+
# def test8_get_delta_link(self):
5353
# result = self.client.me.drive.root.delta.token("latest").get().execute_query()
5454
# self.assertIsNotNone(result.resource_path)

tests/onedrive/test_excel_worksheets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test3_used_range(self):
4141

4242
def test4_protect_worksheet(self):
4343
ws = self.__class__.worksheet
44-
options = WorkbookWorksheetProtectionOptions(allowDeleteRows=False)
44+
options = WorkbookWorksheetProtectionOptions(allow_delete_rows=False)
4545
ws.protection.protect(options).execute_query()
4646
result = ws.protection.get().execute_query()
4747
self.assertFalse(result.options.allowDeleteRows)

0 commit comments

Comments
 (0)