Skip to content

Commit ff882c6

Browse files
committed
OneDrive API: introduced Site and another resources. Refactorings
1 parent fe44920 commit ff882c6

35 files changed

+193
-132
lines changed

.idea/.gitignore

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# About
2-
Office 365 Library for Python
2+
Office 365 & Microsoft Graph Library for Python
33

4-
The list of supported Office 365 APIs:
4+
The list of supported APIs:
55

66
- [SharePoint REST API](https://msdn.microsoft.com/en-us/library/office/jj860569.aspx) (_supported_ versions: [SharePoint 2013](https://msdn.microsoft.com/library/office/jj860569(v=office.15).aspx), SharePoint 2016, SharePoint Online and OneDrive for Business)
77
- [Outlook REST API](https://msdn.microsoft.com/en-us/office/office365/api/use-outlook-rest-api#DefineOutlookRESTAPI)
88
- [Outlook Contacts REST API](https://msdn.microsoft.com/en-us/office/office365/api/contacts-rest-operations)
99
- [Outlook Calendar REST API](https://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations)
1010
- [Outlook Mail REST API](https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations)
11+
- [OneDrive API](https://docs.microsoft.com/en-us/graph/api/resources/onedrive?view=graph-rest-1.0)
1112

1213

1314
## Status
@@ -24,7 +25,9 @@ pip install Office365-REST-Python-Client
2425
```
2526

2627

27-
# Usage: working with SharePoint resources
28+
# Usage
29+
30+
## Working with SharePoint resources
2831

2932
There are **two approaches** available to perform REST queries:
3033

@@ -74,12 +77,13 @@ else:
7477

7578

7679
# Python Version
77-
Python 2.7 is fully supported.
80+
Python `2.7 & 3.4–3.6` are supported.
7881

7982

8083
# Third Party Libraries and Dependencies
8184
The following libraries will be installed when you install the client library:
8285
* [requests](https://github.com/kennethreitz/requests)
86+
* [adal](https://github.com/AzureAD/azure-activedirectory-library-for-python)
8387

8488

8589

examples/sharepoint/listitems_operations_alt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22

3+
from office365.sharepoint.client_context import ClientContext
34
from settings import settings
45
from office365.runtime.auth.authentication_context import AuthenticationContext
56
from office365.runtime.client_request import ClientRequest

office365/onedrive/base_item.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ def id(self):
1717
return self.properties['id']
1818
return None
1919

20+
@property
21+
def etag(self):
22+
"""ETag for the item."""
23+
if self.is_property_available("eTag"):
24+
return self.properties['eTag']
25+
return None
26+
2027
@property
2128
def created_by(self):
2229
"""Identity of the user, device, or application which created the item."""

office365/onedrive/drive_item.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
from office365.onedrive.base_item import BaseItem
2+
from office365.runtime.resource_path_entity import ResourcePathEntity
23

34

45
class DriveItem(BaseItem):
56
"""The driveItem resource represents a file, folder, or other item stored in a drive. All file system objects in
67
OneDrive and SharePoint are returned as driveItem resources """
8+
9+
def item_with_path(self, path):
10+
"""Retrieve DriveItem by path"""
11+
return DriveItem(self.context,
12+
ResourcePathEntity(self.context, self.resource_path, ':/{0}'.format(path)))
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
from office365.onedrive.drive_item import DriveItem
22
from office365.runtime.client_object_collection import ClientObjectCollection
3+
from office365.runtime.resource_path_entity import ResourcePathEntity
34

45

56
class DriveItemCollection(ClientObjectCollection):
67
"""Drive items's collection"""
78

89
def __init__(self, context, resource_path=None):
910
super(DriveItemCollection, self).__init__(context, DriveItem, resource_path)
11+
12+
def get_by_id(self, _id):
13+
"""Retrieve DriveItem by unique identifier"""
14+
return DriveItem(self.context,
15+
ResourcePathEntity(self.context, self.resource_path, _id))

office365/onedrive/sharepoint_ids.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from office365.runtime.client_value_object import ClientValueObject
2+
3+
4+
class SharePointIds(ClientValueObject):
5+
"""The SharePointIds resource groups the various identifiers for an item stored in a SharePoint site or OneDrive
6+
for Business into a single structure. """

office365/onedrive/site.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from office365.onedrive.base_item import BaseItem
2+
3+
4+
class Site(BaseItem):
5+
"""The site resource provides metadata and relationships for a SharePoint site. """
6+
7+
@property
8+
def sharepointids(self):
9+
"""Returns identifiers useful for SharePoint REST compatibility."""
10+
if self.is_property_available("sharepointIds"):
11+
return self.properties['sharepointIds']
12+
return None

office365/onedrive/site_collection.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from office365.runtime.client_value_object import ClientValueObject
2+
3+
4+
class SiteCollection(ClientValueObject):
5+
"""The siteCollection resource provides more information about a site collection. """
6+
7+
def __init__(self):
8+
super(SiteCollection, self).__init__()
9+
self._hostname = None
10+
self._root = None
11+
12+
@property
13+
def hostname(self):
14+
"""The hostname for the site collection."""
15+
return self._hostname
16+
17+
@property
18+
def root(self):
19+
"""If present, indicates that this is a root site collection in SharePoint."""
20+
return self._root
21+
22+

office365/runtime/action_type.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class ActionType:
2-
"""Http method"""
2+
"""Query type"""
33

44
def __init__(self):
55
pass
66

7-
ReadEntry = 1
8-
CreateEntry = 2
9-
UpdateEntry = 3
10-
DeleteEntry = 4
7+
ReadEntity = 1
8+
CreateEntity = 2
9+
UpdateEntity = 3
10+
DeleteEntity = 4
1111
GetMethod = 5
1212
PostMethod = 6

0 commit comments

Comments
 (0)