Notifications
This part of the documentation covers the notifications module which containsall of the classes used to represent notification objects in github3.py.
Notification Objects
- classgithub3.notifications.Thread(json,session:GitHubSession)
Object representing a notification thread.
Changed in version 1.0.0:The
comment
,thread
, andurl
attributes are no longerpresent because GitHub stopped returning the comment that causedthe notification.The
is_unread
method was removed since it just returned theunread
attribute.This object has the following attributes:
- id
The unique identifier for this notification across all GitHubnotifications.
- last_read_at
A
datetime
object representing the date and timewhen the authenticated user last read this thread.
- reason
The reason the authenticated user is receiving this notification.
- repository
A
ShortRepository
this thread originated on.
- subject
A dictionary with the subject of the notification, for example, whichissue, pull request, or diff this is in relation to.
- unread
A boolean attribute indicating whether this thread has been read ornot.
- updated_at
A
datetime
representing the date and time when thisthread was last updated.
See also:http://developer.github.com/v3/activity/notifications/
- as_dict()
Return the attributes for this object as a dictionary.
This is equivalent to calling:
json.loads(obj.as_json())
- Returns:
this object’s attributes serialized to a dictionary
- Return type:
dict
- as_json()
Return the json data for this object.
This is equivalent to calling:
json.dumps(obj.as_dict())
- Returns:
this object’s attributes as a JSON string
- Return type:
str
- delete_subscription()
Delete subscription for this thread.
- Returns:
True if successful, False otherwise
- Return type:
bool
- classmethodfrom_dict(json_dict,session)
Return an instance of this class formed from
json_dict
.
- classmethodfrom_json(json,session)
Return an instance of this class formed from
json
.
- mark()
Mark the thread as read.
- Returns:
True if successful, False otherwise
- Return type:
bool
- new_session()
Generate a new session.
- Returns:
A brand new session
- Return type:
- propertyratelimit_remaining
Number of requests before GitHub imposes a ratelimit.
- Returns:
int
- refresh(conditional:bool=False)→GitHubCore
Re-retrieve the information for this object.
The reasoning for the return value is the following example:
repos=[r.refresh()forring.repositories_by('kennethreitz')]
Without the return value, that would be an array of
None
’s and youwould otherwise have to do:repos=[rforiing.repositories_by('kennethreitz')][r.refresh()forrinrepos]
Which is really an anti-pattern.
Changed in version 0.5.
- Parameters:
conditional (bool) – If True, then we will search for a storedheader (‘Last-Modified’, or ‘ETag’) on the object and send thatas described in theConditional Requests section of the docs
- Returns:
self
- set_subscription(subscribed,ignored)
Set the user’s subscription for this thread.
- Parameters:
subscribed (bool) – (required), determines if notifications should be received fromthis thread.
ignored (bool) – (required), determines if notifications should be ignored from thisthread.
- Returns:
new subscription
- Return type:
- subscription()
Check the status of the user’s subscription to this thread.
- Returns:
the subscription for this thread
- Return type:
- classgithub3.notifications.ThreadSubscription(json,session:GitHubSession)
This object provides a representation of a thread subscription.
See also:developer.github.com/v3/activity/notifications/#get-a-thread-subscription
Changed in version 1.0.0:The
is_ignored
andis_subscribed
methods were removed. Use the:attr`ignored` andsubscribed
attributes instead.This object has the following attributes:
- created_at
A
datetime
object representing the date and timethe user was subscribed to the thread.
- ignored
A boolean attribute indicating whether the user ignored this.
- reason
The reason the user is subscribed to the thread.
- subscribed
A boolean attribute indicating whether the user is subscribed or not.
- thread_url
The URL of the thread resource in the GitHub API.
- as_dict()
Return the attributes for this object as a dictionary.
This is equivalent to calling:
json.loads(obj.as_json())
- Returns:
this object’s attributes serialized to a dictionary
- Return type:
dict
- as_json()
Return the json data for this object.
This is equivalent to calling:
json.dumps(obj.as_dict())
- Returns:
this object’s attributes as a JSON string
- Return type:
str
- delete()
Delete this subscription.
- Returns:
True if successful, False otherwise
- Return type:
bool
- classmethodfrom_dict(json_dict,session)
Return an instance of this class formed from
json_dict
.
- classmethodfrom_json(json,session)
Return an instance of this class formed from
json
.
- new_session()
Generate a new session.
- Returns:
A brand new session
- Return type:
- propertyratelimit_remaining
Number of requests before GitHub imposes a ratelimit.
- Returns:
int
- refresh(conditional:bool=False)→GitHubCore
Re-retrieve the information for this object.
The reasoning for the return value is the following example:
repos=[r.refresh()forring.repositories_by('kennethreitz')]
Without the return value, that would be an array of
None
’s and youwould otherwise have to do:repos=[rforiing.repositories_by('kennethreitz')][r.refresh()forrinrepos]
Which is really an anti-pattern.
Changed in version 0.5.
- Parameters:
conditional (bool) – If True, then we will search for a storedheader (‘Last-Modified’, or ‘ETag’) on the object and send thatas described in theConditional Requests section of the docs
- Returns:
self
- set(subscribed,ignored)
Set the user’s subscription for this subscription.
- Parameters:
subscribed (bool) – (required), determines if notifications should be received fromthis thread.
ignored (bool) – (required), determines if notifications should be ignored from thisthread.
- classgithub3.notifications.RepositorySubscription(json,session:GitHubSession)
This object provides a representation of a thread subscription.
See also:developer.github.com/v3/activity/notifications/#get-a-thread-subscription
Changed in version 1.0.0:The
is_ignored
andis_subscribed
methods were removed. Use the:attr`ignored` andsubscribed
attributes instead.This object has the following attributes:
- created_at
A
datetime
object representing the date and timethe user was subscribed to the thread.
- ignored
A boolean attribute indicating whether the user ignored this.
- reason
The reason the user is subscribed to the thread.
- repository_url
The URL of the repository resource in the GitHub API.
- subscribed
A boolean attribute indicating whether the user is subscribed or not.
- as_dict()
Return the attributes for this object as a dictionary.
This is equivalent to calling:
json.loads(obj.as_json())
- Returns:
this object’s attributes serialized to a dictionary
- Return type:
dict
- as_json()
Return the json data for this object.
This is equivalent to calling:
json.dumps(obj.as_dict())
- Returns:
this object’s attributes as a JSON string
- Return type:
str
- delete()
Delete this subscription.
- Returns:
True if successful, False otherwise
- Return type:
bool
- classmethodfrom_dict(json_dict,session)
Return an instance of this class formed from
json_dict
.
- classmethodfrom_json(json,session)
Return an instance of this class formed from
json
.
- new_session()
Generate a new session.
- Returns:
A brand new session
- Return type:
- propertyratelimit_remaining
Number of requests before GitHub imposes a ratelimit.
- Returns:
int
- refresh(conditional:bool=False)→GitHubCore
Re-retrieve the information for this object.
The reasoning for the return value is the following example:
repos=[r.refresh()forring.repositories_by('kennethreitz')]
Without the return value, that would be an array of
None
’s and youwould otherwise have to do:repos=[rforiing.repositories_by('kennethreitz')][r.refresh()forrinrepos]
Which is really an anti-pattern.
Changed in version 0.5.
- Parameters:
conditional (bool) – If True, then we will search for a storedheader (‘Last-Modified’, or ‘ETag’) on the object and send thatas described in theConditional Requests section of the docs
- Returns:
self
- set(subscribed,ignored)
Set the user’s subscription for this subscription.
- Parameters:
subscribed (bool) – (required), determines if notifications should be received fromthis thread.
ignored (bool) – (required), determines if notifications should be ignored from thisthread.