Models
This part of the documentation covers a lot of lower-level objects that arenever directly seen or used by the user (developer). They are documented forfuture developers of this library.
Warning
These classes are only to be used internally in development of thislibrary.
- classgithub3.models.GitHubCore(json,session:GitHubSession)
The base object for all objects that require a session.
The
GitHubCore
object provides somebasic attributes and methods to other sub-classes that are very useful tohave.- 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
- 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