Notifications¶
This part of the documentation covers the notifications module which contains all of the classes used to represent notification objects in github3.py.
Notification Objects¶
- class github3.notifications.Thread(json, session: GitHubSession)¶
Object representing a notification thread.
Changed in version 1.0.0: The
comment
,thread
, andurl
attributes are no longer present because GitHub stopped returning the comment that caused the 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 GitHub notifications.
- last_read_at¶
A
datetime
object representing the date and time when 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, which issue, pull request, or diff this is in relation to.
- unread¶
A boolean attribute indicating whether this thread has been read or not.
- updated_at¶
A
datetime
representing the date and time when this thread 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
- classmethod from_dict(json_dict, session)¶
Return an instance of this class formed from
json_dict
.
- classmethod from_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
- property ratelimit_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() for r in g.repositories_by('kennethreitz')]
Without the return value, that would be an array of
None
’s and you would otherwise have to do:repos = [r for i in g.repositories_by('kennethreitz')] [r.refresh() for r in repos]
Which is really an anti-pattern.
Changed in version 0.5.
- Parameters
conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional 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 from this thread.
ignored (bool) – (required), determines if notifications should be ignored from this thread.
- 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
- class github3.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 time the 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
- classmethod from_dict(json_dict, session)¶
Return an instance of this class formed from
json_dict
.
- classmethod from_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
- property ratelimit_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() for r in g.repositories_by('kennethreitz')]
Without the return value, that would be an array of
None
’s and you would otherwise have to do:repos = [r for i in g.repositories_by('kennethreitz')] [r.refresh() for r in repos]
Which is really an anti-pattern.
Changed in version 0.5.
- Parameters
conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional 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 from this thread.
ignored (bool) – (required), determines if notifications should be ignored from this thread.
- class github3.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 time the 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
- classmethod from_dict(json_dict, session)¶
Return an instance of this class formed from
json_dict
.
- classmethod from_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
- property ratelimit_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() for r in g.repositories_by('kennethreitz')]
Without the return value, that would be an array of
None
’s and you would otherwise have to do:repos = [r for i in g.repositories_by('kennethreitz')] [r.refresh() for r in repos]
Which is really an anti-pattern.
Changed in version 0.5.
- Parameters
conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional 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 from this thread.
ignored (bool) – (required), determines if notifications should be ignored from this thread.