Skip to content

Commit f5230e8

Browse files
committed
updates for workbooks namespace in OneDrive API
1 parent 1d4d0f6 commit f5230e8

File tree

29 files changed

+341
-22
lines changed

29 files changed

+341
-22
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Enumerates files along with role assignments
3+
"""
4+
5+
from office365.sharepoint.client_context import ClientContext
6+
from office365.sharepoint.listitems.listitem import ListItem
7+
from office365.sharepoint.principal.type import PrincipalType
8+
from tests import test_client_credentials, test_team_site_url
9+
10+
ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)
11+
doc_lib = ctx.web.default_document_library()
12+
# retrieve all the files from a library
13+
items = (
14+
doc_lib.items.select(["FSObjType", "EncodedAbsUrl", "Id"])
15+
.filter("FSObjType eq 0")
16+
.get_all()
17+
.execute_query()
18+
)
19+
20+
# per every list item (file facet) retrieve role assignments (where role assignment is associated with a principal,
21+
# which could be a user or a group)
22+
for item in items: # type: ListItem
23+
role_assignments = item.role_assignments.expand(["Member"]).get().execute_query()
24+
print("File: {0}".format(item.properties["EncodedAbsUrl"]))
25+
for ra in role_assignments:
26+
if ra.member.principal_type == PrincipalType.SharePointGroup:
27+
print(ra.member)

generator/import_metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ def export_to_file(path, content):
2626
"--endpoint",
2727
dest="endpoint",
2828
help="Import metadata endpoint",
29-
default="graph",
29+
default="sharepoint",
3030
)
3131
parser.add_argument(
3232
"-p",
3333
"--path",
3434
dest="path",
35-
default="./metadata/Graph.xml",
35+
default="./metadata/SharePoint.xml",
3636
help="Import metadata endpoint",
3737
)
3838

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from office365.entity import Entity
2+
3+
4+
class Approval(Entity):
5+
"""Represents the approval object for decisions associated with a request.
6+
7+
In PIM for groups, the approval object for decisions to approve or deny requests to activate
8+
group membership or ownership."""
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
1+
from office365.directory.identitygovernance.privilegedaccess.approval import Approval
2+
from office365.directory.identitygovernance.privilegedaccess.group_assignment_schedule_instance import (
3+
PrivilegedAccessGroupAssignmentScheduleInstance,
4+
)
15
from office365.entity import Entity
6+
from office365.entity_collection import EntityCollection
7+
from office365.runtime.paths.resource_path import ResourcePath
28

39

410
class PrivilegedAccessGroup(Entity):
511
"""The entry point for all resources related to Privileged Identity Management (PIM) for groups."""
12+
13+
@property
14+
def assignment_approvals(self):
15+
""" """
16+
return self.properties.get(
17+
"assignmentApprovals",
18+
EntityCollection(
19+
self.context,
20+
Approval,
21+
ResourcePath("assignmentApprovals", self.resource_path),
22+
),
23+
)
24+
25+
@property
26+
def assignment_schedule_instances(self):
27+
"""The instances of assignment schedules to activate a just-in-time access."""
28+
return self.properties.get(
29+
"assignmentScheduleInstances",
30+
EntityCollection(
31+
self.context,
32+
PrivilegedAccessGroupAssignmentScheduleInstance,
33+
ResourcePath("assignmentScheduleInstances", self.resource_path),
34+
),
35+
)

office365/directory/identitygovernance/userconsent/request_collection.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
UserConsentRequest,
33
)
44
from office365.entity_collection import EntityCollection
5+
from office365.runtime.queries.function import FunctionQuery
56

67

78
class UserConsentRequestCollection(EntityCollection[UserConsentRequest]):
@@ -11,3 +12,12 @@ def __init__(self, context, resource_path=None):
1112
super(UserConsentRequestCollection, self).__init__(
1213
context, UserConsentRequest, resource_path
1314
)
15+
16+
def filter_by_current_user(self, on):
17+
"""Retrieve a collection of userConsentRequest objects for accessing a specified app, for which the current
18+
user is the reviewer."""
19+
return_type = UserConsentRequestCollection(self.context, self.resource_path)
20+
params = {"on": on}
21+
qry = FunctionQuery(self, "filterByCurrentUser", params, return_type)
22+
self.context.add_query(qry)
23+
return return_type
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class WebPartData(ClientValue):
5+
""""""
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
from typing import Optional
2+
3+
from office365.onedrive.sitepages.webparts.data import WebPartData
14
from office365.onedrive.sitepages.webparts.web_part import WebPart
25

36

47
class StandardWebPart(WebPart):
58
"""Represents a standard web part instance on a SharePoint page."""
9+
10+
@property
11+
def data(self):
12+
# type: () -> Optional[WebPartData]
13+
"""Data of the webPart."""
14+
return self.properties.get("data", WebPartData())

office365/onedrive/workbooks/charts/chart.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from office365.entity import Entity
2+
from office365.entity_collection import EntityCollection
23
from office365.onedrive.workbooks.charts.axes import WorkbookChartAxes
34
from office365.onedrive.workbooks.charts.data_labels import WorkbookChartDataLabels
5+
from office365.onedrive.workbooks.charts.legend import WorkbookChartLegend
6+
from office365.onedrive.workbooks.charts.series.series import WorkbookChartSeries
7+
from office365.onedrive.workbooks.charts.title import WorkbookChartTitle
48
from office365.runtime.client_result import ClientResult
59
from office365.runtime.paths.resource_path import ResourcePath
610
from office365.runtime.queries.function import FunctionQuery
@@ -55,14 +59,44 @@ def axes(self):
5559

5660
@property
5761
def data_labels(self):
58-
"""Represents the datalabels on the chart."""
62+
"""Represents the data labels on the chart."""
5963
return self.properties.get(
6064
"dataLabels",
6165
WorkbookChartDataLabels(
6266
self.context, ResourcePath("dataLabels", self.resource_path)
6367
),
6468
)
6569

70+
@property
71+
def legend(self):
72+
"""Represents the legend on the chart."""
73+
return self.properties.get(
74+
"legend",
75+
WorkbookChartLegend(
76+
self.context, ResourcePath("legend", self.resource_path)
77+
),
78+
)
79+
80+
@property
81+
def series(self):
82+
"""Represents chart series."""
83+
return self.properties.get(
84+
"series",
85+
EntityCollection(
86+
self.context,
87+
WorkbookChartSeries,
88+
ResourcePath("series", self.resource_path),
89+
),
90+
)
91+
92+
@property
93+
def title(self):
94+
"""Represents the title on the chart."""
95+
return self.properties.get(
96+
"title",
97+
WorkbookChartTitle(self.context, ResourcePath("title", self.resource_path)),
98+
)
99+
66100
@property
67101
def worksheet(self):
68102
"""The worksheet containing the current chart."""

office365/onedrive/workbooks/charts/legend.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@
33

44
class WorkbookChartLegend(Entity):
55
"""Represents the legend in a chart."""
6-
7-
pass
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from office365.entity import Entity
2+
3+
4+
class WorkbookChartPoint(Entity):
5+
"""Represents a point of a series in a chart."""

0 commit comments

Comments
 (0)