Gist API Objects — github3.py 4.0.1 documentation (original) (raw)
The Gists API has a rich set of objects it returns.
Gist Representations
class github3.gists.gist.ShortGist(json, session: GitHubSession)
Short representation of a gist.
GitHub’s API returns different amounts of information about gists based upon how that information is retrieved. This object exists to represent the full amount of information returned for a specific gist. For example, you would receive this class when callingall_gists()
. To provide a clear distinction between the types of gists, github3.py uses different classes with different sets of attributes.
This object only has the following attributes:
url
The GitHub API URL for this repository, e.g.,https://api.github.com/gists/6faaaeb956dec3f51a9bd630a3490291
.
Number of comments on this gist
description
Description of the gist as written by the creator
html_url
The URL of this gist on GitHub, e.g.,https://gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291
id
The unique identifier for this gist.
public
This is a boolean attribute describing if the gist is public or private
git_pull_url
The git URL to pull this gist, e.g.,git://gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291.git
git_push_url
The git URL to push to gist, e.g.,git@gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291.git
created_at
This is a datetime object representing when the gist was created.
updated_at
This is a datetime object representing the last time this gist was
most recently updated.
owner
This attribute is a ShortUser object representing the creator of the gist.
files
A dictionary mapping the filename to aGistFile
object.
Changed in version 1.0.0: Previously this was a list but it has been converted to a dictionary to preserve the structure of the API.
The URL to retrieve the list of comments on the Gist via the API.
class github3.gists.gist.GistFork(json, session: GitHubSession)
This object represents a forked Gist.
This has a subset of attributes of aShortGist:
created_at
The date and time when the gist was created.
id
The unique identifier of the gist.
owner
The user who forked the gist.
updated_at
The date and time of the most recent modification of the fork.
url
The API URL for the fork.
class github3.gists.gist.Gist(json, session: GitHubSession)
This object constitutes the full representation of a Gist.
GitHub’s API returns different amounts of information about gists based upon how that information is retrieved. This object exists to represent the full amount of information returned for a specific gist. For example, you would receive this class when callinggist(). To provide a clear distinction between the types of gists, github3.py uses different classes with different sets of attributes.
This object has all the same attributes asShortGist as well as:
commits_url
The URL to retrieve gist commits from the GitHub API.
original_forks
A list of GistFork objects representing each fork of this gist. To retrieve the most recent list of forks, use the forks()
method.
forks_url
The URL to retrieve the current listing of forks of this gist.
history
A list of GistHistory objects representing each change made to this gist.
truncated
This is a boolean attribute that indicates whether the content of this Gist has been truncated or not.
Files in a Gist
Gists have files which have two representations:
class github3.gists.file.GistFile(json, session: GitHubSession)
This represents the full file object returned by interacting with gists.
The object has all of the attributes as returned by the API for a ShortGistFile as well as:
truncated
A boolean attribute that indicates whether original_contentcontains all of the file’s contents.
original_content
The contents of the file (potentially truncated) returned by the API. If the file was truncated use content()
to retrieve it in its entirety.
class github3.gists.file.ShortGistFile(json, session: GitHubSession)
This represents the file object returned by interacting with gists.
The object has the following attributes as returned by the API for a Gist:
raw_url
This URL provides access to the complete, untruncated content of the file represented by this object.
filename
The string for the filename.
language
The GitHub detected language for the file, e.g., Erlang, Python, text.
type
The mime-type of the file. Related to language.
size
The file size in bytes.
The History of a Gist
class github3.gists.history.GistHistory(json, session: GitHubSession)
This object represents one version (or revision) of a gist.
The GitHub API returns the following attributes:
url
The URL to the revision of the gist retrievable through the API.
version
The commit ID of the revision of the gist.
user
The ShortUser representation of the user who owns this gist.
committed_at
The date and time of the revision’s commit.
change_status
A dictionary with the number of deletions, additions, and total changes to the gist.
For convenience, github3.py also exposes the following attributes from thechange_status:
additions
The number of additions to the gist compared to the previous revision.
deletions
The number of deletions from the gist compared to the previous revision.
total
The total number of changes to the gist compared to the previous revision.