forked from xybu/onedrived-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[webhook] Tentative implementation of webhook-based differential update.
Signed-off-by: Xiangyu Bu <[email protected]>
- Loading branch information
Showing
16 changed files
with
712 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console_ui: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
""" | ||
webhook_notification.py | ||
Implementation of the datatypes used in OneDrive webhook notification, which is absent | ||
from official OneDrive Python SDK. | ||
:copyright: (c) Xiangyu Bu <[email protected]> | ||
:license: MIT | ||
""" | ||
|
||
from .. import od_dateutils | ||
|
||
|
||
class WebhookNotification: | ||
|
||
""" https://dev.onedrive.com/resources/webhookNotifiation.htm """ | ||
|
||
def __init__(self, prop_dict): | ||
self._prop_dict = prop_dict | ||
|
||
@property | ||
def context(self): | ||
""" | ||
:return str | None: | ||
An optional string value that is passed back in the notification message for this subscription. | ||
""" | ||
if 'context' in self._prop_dict: | ||
return self._prop_dict['context'] | ||
return None | ||
|
||
@property | ||
def expiration_datetime(self): | ||
""" | ||
:return arrow.Arrow: The date and time when the subscription will expire if not updated or renewed. | ||
""" | ||
return od_dateutils.str_to_datetime(self._prop_dict['expirationDateTime']) | ||
|
||
@property | ||
def resource(self): | ||
""" | ||
:return str: URL to the item where the subscription is registered. | ||
""" | ||
return self._prop_dict['resource'] | ||
|
||
@property | ||
def subscription_id(self): | ||
""" | ||
:return str: The unique identifier for the subscription resource. | ||
""" | ||
return self._prop_dict['subscriptionId'] | ||
|
||
@property | ||
def tenant_id(self): | ||
""" | ||
:return str: | ||
Unique identifier for the tenant which generated this notification. | ||
This is only returned for OneDrive for Business and SharePoint. | ||
""" | ||
if 'tenantId' in self._prop_dict: | ||
return self._prop_dict['tenantId'] | ||
return None | ||
|
||
@property | ||
def user_id(self): | ||
""" | ||
:return str: Unique identifier for the drive which generated this notification. | ||
""" | ||
return self._prop_dict['userId'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.