Models

This part of the documentation covers a lot of lower-level objects that are never directly seen or used by the user (developer). They are documented for future developers of this library.

Objects

class github3.models.GitHubCore(json, session=None)

The GitHubCore object. This class provides some basic attributes to other classes that are very useful to have.

from_json(json)

Return an instance of cls formed from json.

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

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

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('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.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

to_json()

Return the json representing this object.


class github3.models.BaseAccount(acct, session)

The BaseAccount object. This is used to do the heavy lifting for Organization and User objects.

avatar_url = None

URL of the avatar at gravatar

bio = None

Markdown formatted biography

blog = None

URL of the blog

company = None

Name of the company

created_at = None

datetime object representing the date the account was created

email = None

E-mail address of the user/org

followers = None

Number of followers

following = None

Number of people the user is following

from_json(json)

Return an instance of cls formed from json.

html_url = None

URL of the user/org’s profile

id = None

Unique ID of the account

location = None

Location of the user/org

login = None

login name of the user/org

name = None

Real name of the user/org

public_repos = None

Number of public repos owned by the user/org

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

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

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('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.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

to_json()

Return the json representing this object.

type = None

Tells you what type of account this is


class github3.models.BaseComment(comment, session)

The BaseComment object. A basic class for Gist, Issue and Pull Request Comments.

body = None

Body of the comment. (As written by the commenter)

body_html = None

Body of the comment formatted as html.

body_text = None

Body of the comment formatted as plain-text. (Stripped of markdown, etc.)

created_at = None

datetime object representing when the comment was created.

delete()

Delete this comment.

Returns:bool
edit(body)

Edit this comment.

Parameters:body (str) – (required), new body of the comment, Markdown formatted
Returns:bool
from_json(json)

Return an instance of cls formed from json.

html_url = None

The url of this comment at GitHub

id = None

Unique ID of the comment.

pull_request_url = None

The url of the pull request, if it exists

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

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

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('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.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

to_json()

Return the json representing this object.

updated_at = None

datetime object representing when the comment was updated.


class github3.models.BaseCommit(commit, session)

The BaseCommit object. This serves as the base for the various types of commit objects returned by the API.

from_json(json)

Return an instance of cls formed from json.

html_url = None

URL to view the commit on GitHub

message = None

Commit message

parents = None

List of parents to this commit.

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

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

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('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.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

sha = None

SHA of this commit.

to_json()

Return the json representing this object.