Skip to content

Commit 5122653

Browse files
committed
OneDrive API enhancements: new types and methods
1 parent 2668221 commit 5122653

File tree

16 files changed

+93
-47
lines changed

16 files changed

+93
-47
lines changed

office365/directory/rbac/__init__.py

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from office365.entity import Entity
2+
3+
4+
class RbacApplication(Entity):
5+
"""Role management container for unified role definitions and role assignments for Microsoft 365 role-based
6+
access control (RBAC) providers. The role assignments support only a single principal and a single scope.
7+
Currently directory and entitlementManagement are the two RBAC providers supported."""

office365/directory/roles/__init__.py

Whitespace-only changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from office365.directory.rbac.application import RbacApplication
2+
from office365.entity import Entity
3+
from office365.runtime.paths.resource_path import ResourcePath
4+
5+
6+
class RoleManagement(Entity):
7+
"""
8+
Represents a Microsoft 365 role-based access control (RBAC) role management entity.
9+
This resource provides access to role definitions and role assignments surfaced from RBAC providers.
10+
directory (Azure Active Directory), entitlementManagement, and deviceManagement (Intune) providers
11+
are currently supported.
12+
"""
13+
14+
@property
15+
def directory(self):
16+
return self.properties.get('directory',
17+
RbacApplication(self.context, ResourcePath("directory", self.resource_path)))
File renamed without changes.

office365/graph_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from office365.directory.internal.paths.me import MePath
1515
from office365.directory.licenses.subscribed_sku import SubscribedSku
1616
from office365.directory.resource_specific_permission_grant import ResourceSpecificPermissionGrant
17+
from office365.directory.roles.management import RoleManagement
1718
from office365.intune.organizations.org_contact import OrgContact
1819
from office365.intune.organizations.organization import Organization
1920
from office365.directory.policies.root import PolicyRoot
@@ -235,6 +236,10 @@ def reports(self):
235236
"""
236237
return ReportRoot(self, ResourcePath("reports"))
237238

239+
@property
240+
def role_management(self):
241+
return RoleManagement(self, ResourcePath("roleManagement"))
242+
238243
@property
239244
def teams_templates(self):
240245
"""
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 ItemActionStat(ClientValue):
5+
"""The itemActionStat resource provides aggregate details about an action over a period of time."""
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1+
from office365.directory.identities.identity_set import IdentitySet
12
from office365.entity import Entity
3+
from office365.runtime.paths.resource_path import ResourcePath
24

35

46
class ItemActivity(Entity):
57
"""
68
The itemActivity resource provides information about activities that took place on an item or within a container.
79
Currently only available on SharePoint and OneDrive for Business.
810
"""
9-
pass
11+
12+
@property
13+
def actor(self):
14+
"""Identity of who performed the action."""
15+
return self.properties.get("actor", IdentitySet())
16+
17+
@property
18+
def drive_item(self):
19+
"""Exposes the driveItem that was the target of this activity."""
20+
from office365.onedrive.driveitems.driveItem import DriveItem
21+
return self.properties.get('driveItem',
22+
DriveItem(self.context, ResourcePath("driveItem", self.resource_path)))
23+
24+
def get_property(self, name, default_value=None):
25+
if default_value is None:
26+
property_mapping = {
27+
"driveItem": self.drive_item,
28+
}
29+
default_value = property_mapping.get(name, None)
30+
return super(ItemActivity, self).get_property(name, default_value)

office365/onedrive/driveitems/driveItem.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from office365.runtime.client_result import ClientResult
3030
from office365.runtime.http.http_method import HttpMethod
3131
from office365.runtime.queries.create_entity import CreateEntityQuery
32+
from office365.runtime.queries.function import FunctionQuery
3233
from office365.runtime.queries.service_operation import ServiceOperationQuery
3334
from office365.runtime.paths.resource_path import ResourcePath
3435
from office365.runtime.queries.upload_session import UploadSessionQuery
@@ -306,15 +307,7 @@ def search(self, query_text):
306307
:type query_text: str
307308
"""
308309
return_type = EntityCollection(self.context, DriveItem, ResourcePath("items", self.resource_path))
309-
qry = ServiceOperationQuery(self, "search", {"q": query_text}, None, None, return_type)
310-
311-
def _construct_query(request):
312-
"""
313-
:type request: office365.runtime.http.request_options.RequestOptions
314-
"""
315-
request.method = HttpMethod.Get
316-
317-
self.context.before_execute(_construct_query)
310+
qry = FunctionQuery(self, "search", {"q": query_text}, return_type)
318311
self.context.add_query(qry)
319312
return return_type
320313

@@ -361,13 +354,8 @@ def get_activities_by_interval(self, start_dt=None, end_dt=None, interval=None):
361354
"interval": interval
362355
}
363356
return_type = EntityCollection(self.context, ItemActivityStat, self.resource_path)
364-
qry = ServiceOperationQuery(self, "getActivitiesByInterval", params, None, None, return_type)
357+
qry = FunctionQuery(self, "getActivitiesByInterval", params, return_type)
365358
self.context.add_query(qry)
366-
367-
def _construct_request(request):
368-
request.method = HttpMethod.Get
369-
370-
self.context.before_execute(_construct_request)
371359
return return_type
372360

373361
def restore(self, parent_reference, name):

0 commit comments

Comments
 (0)