27 KiB
You don't normaly create instances of any class but Github.
You obtain instances through calls to search_, get_ and create_ methods.
Methods returning an "iterator of SomeType" return an iterator which yields instances of SomeType.
This implements lazy pagination requests.
You can use this iterator in a for f in user.get_followers(): loop or with any itertools functions,
but you cannot know the number of objects returned before the end of the iteration.
If that's really what you need, you cant use len( list( user.get_followers() ) ), which does all the requests needed to enumerate the user's followers.
Note that there is often an attribute giving this value (in that case user.followers).
Class Github
Constructed from user's login and password or OAuth token or nothing:
g = Github( login, password )
g = Github( token )
g = Github()
You can add an argument base_url = "http://my.enterprise.com:8080/path/to/github" to connect to a local install of Github (ie. Github Enterprise).
Attributes
rate_limiting: tuple of two integers: remaining and limit, as explained in Rate Limiting
Methods
get_user():AuthenticatedUserget_user( login ):NamedUserget_organization( login ):Organizationget_gist( id ):Gistid: string
get_gists(): iterator ofGistsearch_repos( keyword ): iterator ofRepositorylegacy_search_repos( keyword, [language] ): iterator ofRepositorykeyword: stringlanguage: string
legacy_search_users( keyword ): iterator ofNamedUserkeyword: string
legacy_search_user_by_email( email ):NamedUseremail: string
render_markdown( text, [context] ): stringtext: stringcontext:Repository
Class GithubException
Attributes
status: integerdata: dict
Class AuthenticatedUser
Attributes
avatar_url: stringbio: stringblog: stringcollaborators: integercompany: stringcreated_at: datetime.datetimedisk_usage: integeremail: stringfollowers: integerfollowing: integergravatar_id: stringhireable: boolhtml_url: stringid: integerlocation: stringlogin: stringname: stringowned_private_repos: integerplan:Planprivate_gists: integerpublic_gists: integerpublic_repos: integertotal_private_repos: integertype: stringurl: string
Authorizations
create_authorization( [scopes, note, note_url] ):Authorizationscopes: list of stringnote: stringnote_url: string
get_authorization( id ):Authorizationid: integer
get_authorizations(): iterator ofAuthorization
Emails
add_to_emails( email, ... )email: string
get_emails(): list of stringremove_from_emails( email, ... )email: string
Events
get_events(): iterator ofEventget_organization_events( org ): iterator ofEventorg:Organization
Followers
get_followers(): iterator ofNamedUser
Following
add_to_following( following )following:NamedUser
get_following(): iterator ofNamedUserhas_in_following( following ): boolfollowing:NamedUser
remove_from_following( following )following:NamedUser
Forking
create_fork( repo ):Repositoryrepo:Repository
Gists
create_gist( public, files, [description] ):Gistpublic: boolfiles: dict of string toInputFileContentdescription: string
get_gists(): iterator ofGistget_starred_gists(): iterator ofGist
Issues
get_issues(): iterator ofIssue
Keys
create_key( title, key ):UserKeytitle: stringkey: string
get_key( id ):UserKeyid: integer
get_keys(): iterator ofUserKey
Modification
edit( [name, email, blog, company, location, hireable, bio] )name: stringemail: stringblog: stringcompany: stringlocation: stringhireable: boolbio: string
Orgs
get_orgs(): iterator ofOrganization
Repos
create_repo( name, [description, homepage, private, has_issues, has_wiki, has_downloads] ):Repositoryname: stringdescription: stringhomepage: stringprivate: boolhas_issues: boolhas_wiki: boolhas_downloads: bool
get_repo( name ):Repositoryname: string
get_repos( [type, sort, direction] ): iterator ofRepositorytype: stringsort: stringdirection: string
Watched
add_to_watched( watched )watched:Repository
get_watched(): iterator ofRepositoryhas_in_watched( watched ): boolwatched:Repository
remove_from_watched( watched )watched:Repository
Class Authorization
Attributes
app:AuthorizationApplicationcreated_at: datetime.datetimeid: integernote: stringnote_url: stringscopes: list of stringtoken: stringupdated_at: datetime.datetimeurl: string
Deletion
delete()
Modification
edit( [scopes, add_scopes, remove_scopes, note, note_url] )scopes: list of stringadd_scopes: list of stringremove_scopes: list of stringnote: stringnote_url: string
Class AuthorizationApplication
Attributes
name: stringurl: string
Class Branch
Attributes
commit:Commitname: string
Class Commit
Attributes
author:NamedUsercommit:GitCommitcommitter:NamedUserfiles: list ofFileparents: list ofCommitsha: stringstats:CommitStatsurl: string
Comments
create_comment( body, [line, path, position] ):CommitCommentbody: stringline: integerpath: stringposition: integer
get_comments(): iterator ofCommitComment
Class CommitComment
Attributes
body: stringcommit_id: stringcreated_at: datetime.datetimehtml_url: stringid: integerline: integerpath: stringposition: integerupdated_at: datetime.datetimeurl: stringuser:NamedUser
Deletion
delete()
Modification
edit( body )body: string
Class CommitStats
Attributes
additions: integerdeletions: integertotal: integer
Class Comparison
Attributes
ahead_by: integerbase_commit:Commitbehind_by: integercommits: list ofCommitdiff_url: stringfiles: list ofFilehtml_url: stringpatch_url: stringpermalink_url: stringstatus: stringtotal_commits: integerurl: string
Class Download
Attributes
accesskeyid: stringacl: stringbucket: stringcontent_type: stringcreated_at: datetime.datetimedescription: stringdownload_count: integerexpirationdate: datetime.datetimehtml_url: stringid: integermime_type: stringname: stringpath: stringpolicy: stringprefix: stringredirect: bools3_url: stringsignature: stringsize: integerurl: string
Deletion
delete()
Class Event
Attributes
actor:NamedUsercreated_at: datetime.datetimeid: stringorg:Organizationpayload: dictpublic: boolrepo:Repositorytype: string
Class File
Attributes
additions: integerblob_url: stringchanges: integerdeletions: integerfilename: stringpatch: stringraw_url: stringsha: stringstatus: string
Class Gist
Attributes
comments: integercreated_at: datetime.datetimedescription: stringfiles: dict of string toGistFilefork_of:Gistforks: list ofGistgit_pull_url: stringgit_push_url: stringhistory: list ofGistHistoryStatehtml_url: stringid: stringpublic: boolupdated_at: datetime.datetimeurl: stringuser:NamedUser
Comments
create_comment( body ):GistCommentbody: string
get_comment( id ):GistCommentid: integer
get_comments(): iterator ofGistComment
Deletion
delete()
Forking
create_fork():Gist
Modification
edit( [description, files] )description: stringfiles: dict of string toInputFileContent
Starring
is_starred(): boolreset_starred()set_starred()
Class GistComment
Attributes
body: stringcreated_at: datetime.datetimeid: integerupdated_at: datetime.datetimeurl: stringuser:NamedUser
Deletion
delete()
Modification
edit( body )body: string
Class GistFile
Attributes
content: stringfilename: stringlanguage: stringraw_url: stringsize: integer
Class GistHistoryState
Attributes
change_status:CommitStatscommitted_at: datetime.datetimeurl: stringuser:NamedUserversion: string
Class GitAuthor
Attributes
date: datetime.datetimeemail: stringname: string
Class GitBlob
Attributes
content: stringencoding: stringsha: stringsize: integerurl: string
Class GitCommit
Attributes
author:GitAuthorcommitter:GitAuthormessage: stringparents: list ofGitCommitsha: stringtree:GitTreeurl: string
Class GitObject
Attributes
sha: stringtype: stringurl: string
Class GitRef
Attributes
object:GitObjectref: stringurl: string
Deletion
delete()
Modification
edit( sha, [force] )sha: stringforce: bool
Class GitTag
Attributes
message: stringobject:GitObjectsha: stringtag: stringtagger:GitAuthorurl: string
Class GitTree
Attributes
sha: stringtree: list ofGitTreeElementurl: string
Class GitTreeElement
Attributes
mode: stringpath: stringsha: stringsize: integertype: stringurl: string
Class Hook
Attributes
active: boolconfig: dictcreated_at: datetime.datetimeevents: list of stringid: integerlast_response:HookResponsename: stringupdated_at: datetime.datetimeurl: string
Deletion
delete()
Modification
edit( name, config, [events, add_events, remove_events, active] )name: stringconfig: dictevents: list of stringadd_events: list of stringremove_events: list of stringactive: bool
Testing
test()
Class HookResponse
Attributes
code: integermessage: stringstatus: string
Class Issue
Attributes
assignee:NamedUserbody: stringclosed_at: datetime.datetimeclosed_by:NamedUsercomments: integercreated_at: datetime.datetimehtml_url: stringid: integerlabels: list ofLabelmilestone:Milestonenumber: integerpull_request:IssuePullRequestrepository:Repositorystate: stringtitle: stringupdated_at: datetime.datetimeurl: stringuser:NamedUser
Comments
create_comment( body ):IssueCommentbody: string
get_comment( id ):IssueCommentid: integer
get_comments(): iterator ofIssueComment
Events
get_events(): iterator ofIssueEvent
Labels
add_to_labels( label, ... )label:Label
delete_labels()get_labels(): iterator ofLabelremove_from_labels( label )label:Label
set_labels( label, ... )label:Label
Modification
edit( [title, body, assignee, state, milestone, labels] )title: stringbody: stringassignee:NamedUserstate: stringmilestone:Milestonelabels: list of string
Class IssueComment
Attributes
body: stringcreated_at: datetime.datetimeid: integerupdated_at: datetime.datetimeurl: stringuser:NamedUser
Deletion
delete()
Modification
edit( body )body: string
Class IssueEvent
Attributes
actor:NamedUsercommit_id: stringcreated_at: datetime.datetimeevent: stringid: integerissue:Issueurl: string
Class IssuePullRequest
Attributes
diff_url: stringhtml_url: stringpatch_url: string
Class Label
Attributes
color: stringname: stringurl: string
Deletion
delete()
Modification
edit( name, color )name: stringcolor: string
Class Milestone
Attributes
closed_issues: integercreated_at: datetime.datetimecreator:NamedUserdescription: stringdue_on: datetime.datetimeid: integernumber: integeropen_issues: integerstate: stringtitle: stringurl: string
Deletion
delete()
Labels
get_labels(): iterator ofLabel
Modification
edit( title, [state, description, due_on] )title: stringstate: stringdescription: stringdue_on: date
Class NamedUser
Attributes
avatar_url: stringbio: stringblog: stringcollaborators: integercompany: stringcontributions: integercreated_at: datetime.datetimedisk_usage: integeremail: stringfollowers: integerfollowing: integergravatar_id: stringhireable: boolhtml_url: stringid: integerlocation: stringlogin: stringname: stringowned_private_repos: integerplan:Planprivate_gists: integerpublic_gists: integerpublic_repos: integertotal_private_repos: integertype: stringurl: string
Events
get_events(): iterator ofEventget_public_events(): iterator ofEventget_received_events(): iterator ofEventget_public_received_events(): iterator ofEvent
Followers
get_followers(): iterator ofNamedUser
Following
get_following(): iterator ofNamedUser
Gists
create_gist( public, files, [description] ):Gistpublic: boolfiles: dict of string toInputFileContentdescription: string
get_gists(): iterator ofGist
Orgs
get_orgs(): iterator ofOrganization
Repos
get_repo( name ):Repositoryname: string
get_repos( [type] ): iterator ofRepositorytype: string
Watched
get_watched(): iterator ofRepository
Class Organization
Attributes
avatar_url: stringbilling_email: stringblog: stringcollaborators: integercompany: stringcreated_at: datetime.datetimedisk_usage: integeremail: stringfollowers: integerfollowing: integergravatar_id: stringhtml_url: stringid: integerlocation: stringlogin: stringname: stringowned_private_repos: integerplan:Planprivate_gists: integerpublic_gists: integerpublic_repos: integertotal_private_repos: integertype: stringurl: string
Events
get_events(): iterator ofEvent
Forking
create_fork( repo ):Repositoryrepo:Repository
Members
get_members(): iterator ofNamedUserhas_in_members( member ): boolmember:NamedUser
remove_from_members( member )member:NamedUser
Modification
edit( [billing_email, blog, company, email, location, name] )billing_email: stringblog: stringcompany: stringemail: stringlocation: stringname: string
Public_members
add_to_public_members( public_member )public_member:NamedUser
get_public_members(): iterator ofNamedUserhas_in_public_members( public_member ): boolpublic_member:NamedUser
remove_from_public_members( public_member )public_member:NamedUser
Repos
create_repo( name, [description, homepage, private, has_issues, has_wiki, has_downloads, team_id] ):Repositoryname: stringdescription: stringhomepage: stringprivate: boolhas_issues: boolhas_wiki: boolhas_downloads: boolteam_id:Team
get_repo( name ):Repositoryname: string
get_repos( [type] ): iterator ofRepositorytype: string
Teams
create_team( name, [repo_names, permission] ):Teamname: stringrepo_names: list ofRepositorypermission: string
get_team( id ):Teamid: integer
get_teams(): iterator ofTeam
Class Permissions
Attributes
admin: boolpull: boolpush: bool
Class Plan
Attributes
collaborators: integername: stringprivate_repos: integerspace: integer
Class PullRequest
Attributes
additions: integerbase:PullRequestPartbody: stringchanged_files: integerclosed_at: datetime.datetimecomments: integercommits: integercreated_at: datetime.datetimedeletions: integerdiff_url: stringhead:PullRequestParthtml_url: stringid: integerissue_url: stringmergeable: boolmerged: boolmerged_at: datetime.datetimemerged_by:NamedUsernumber: integerpatch_url: stringreview_comments: integerstate: stringtitle: stringupdated_at: datetime.datetimeurl: stringuser:NamedUser
Comments
create_comment( body, commit_id, path, position ):PullRequestCommentbody: stringcommit_id:Commitpath: stringposition: integer
get_comment( id ):PullRequestCommentid: integer
get_comments(): iterator ofPullRequestComment
Commits
get_commits(): iterator ofCommit
Files
get_files(): iterator ofFile
Merging
is_merged(): boolmerge( [commit_message] ):PullRequestMergeStatuscommit_message: string
Modification
edit( [title, body, state] )title: stringbody: stringstate: string
Class PullRequestComment
Attributes
body: stringcommit_id: stringcreated_at: datetime.datetimeid: integeroriginal_commit_id: stringoriginal_position: integerpath: stringposition: integerupdated_at: datetime.datetimeurl: stringuser:NamedUser
Deletion
delete()
Modification
edit( body )body: string
Class PullRequestMergeStatus
Attributes
merged: boolmessage: stringsha: string
Class PullRequestPart
Attributes
label: stringref: stringrepo:Repositorysha: stringuser:NamedUser
Class Repository
Attributes
clone_url: stringcreated_at: datetime.datetimedescription: stringfork: boolforks: integerfull_name: stringgit_url: stringhas_downloads: boolhas_issues: boolhas_wiki: boolhomepage: stringhtml_url: stringid: integerlanguage: stringmaster_branch: stringname: stringopen_issues: integerorganization:Organizationowner:NamedUserparent:Repositorypermissions:Permissionsprivate: boolpushed_at: datetime.datetimesize: integersource:Repositoryssh_url: stringsvn_url: stringupdated_at: datetime.datetimeurl: stringwatchers: integer
Deletion
delete()
Comparison
compare( base, head ):Comparisonbase: stringhead: string
Branches
get_branches(): iterator ofBranch
Collaborators
add_to_collaborators( collaborator )collaborator:NamedUser
get_collaborators(): iterator ofNamedUserhas_in_collaborators( collaborator ): boolcollaborator:NamedUser
remove_from_collaborators( collaborator )collaborator:NamedUser
Comments
get_comment( id ):CommitCommentid: integer
get_comments(): iterator ofCommitComment
Commits
get_commit( sha ):Commitsha: string
get_commits( [sha, path] ): iterator ofCommitsha: stringpath: string
Contributors
get_contributors(): iterator ofNamedUser
Downloads
create_download( name, size, [description, content_type] ):Downloadname: stringsize: integerdescription: stringcontent_type: string
get_download( id ):Downloadid: integer
get_downloads(): iterator ofDownload
Events
get_events(): iterator ofEventget_network_events(): iterator ofEvent
Forks
get_forks(): iterator ofRepository
Git_blobs
create_git_blob( content, encoding ):GitBlobcontent: stringencoding: string
get_git_blob( sha ):GitBlobsha: string
Git_commits
create_git_commit( message, tree, parents, [author, committer] ):GitCommitmessage: stringtree:GitTreeparents: list ofGitCommitauthor:InputGitAuthorcommitter:InputGitAuthor
get_git_commit( sha ):GitCommitsha: string
Git_refs
create_git_ref( ref, sha ):GitRefref: stringsha: string
get_git_ref( ref ):GitRefref: string
get_git_refs(): iterator ofGitRef
Git_tags
create_git_tag( tag, message, object, type, [tagger] ):GitTagtag: stringmessage: stringobject: stringtype: stringtagger:InputGitAuthor
get_git_tag( sha ):GitTagsha: string
Git_trees
create_git_tree( tree, [base_tree] ):GitTreetree: list ofInputGitTreeElementbase_tree:GitTree
get_git_tree( sha, [recursive] ):GitTreesha: stringrecursive: bool
Hooks
create_hook( name, config, [events, active] ):Hookname: stringconfig: dictevents: list of stringactive: bool
get_hook( id ):Hookid: integer
get_hooks(): iterator ofHook
Issues
create_issue( title, [body, assignee, milestone, labels] ):Issuetitle: stringbody: stringassignee:NamedUsermilestone:Milestonelabels: list ofLabel
get_issue( number ):Issuenumber: integer
get_issues( [milestone, state, assignee, mentioned, labels, sort, direction, since] ): iterator ofIssuemilestone:Milestoneor "none" or "*"state: stringassignee:NamedUseror "none" or "*"mentioned:NamedUserlabels: list ofLabelsort: stringdirection: stringsince: datetime.datetime
legacy_search_issues( state, keyword ): iterator ofIssuestate: "open" or "closed"keyword: string
Issues_events
get_issues_event( id ):IssueEventid: integer
get_issues_events(): iterator ofIssueEvent
Keys
create_key( title, key ):RepositoryKeytitle: stringkey: string
get_key( id ):RepositoryKeyid: integer
get_keys(): iterator ofRepositoryKey
Labels
create_label( name, color ):Labelname: stringcolor: string
get_label( name ):Labelname: string
get_labels(): iterator ofLabel
Languages
get_languages(): dict of string to integer
Milestones
create_milestone( title, [state, description, due_on] ):Milestonetitle: stringstate: stringdescription: stringdue_on: date
get_milestone( number ):Milestonenumber: integer
get_milestones( [state, sort, direction] ): iterator ofMilestonestate: stringsort: stringdirection: string
Modification
edit( name, [description, homepage, public, has_issues, has_wiki, has_downloads] )name: stringdescription: stringhomepage: stringpublic: boolhas_issues: boolhas_wiki: boolhas_downloads: bool
Pulls
create_pull( < title, body, base, head > or < issue, base, head > ):PullRequesttitle: stringbody: stringissue:Issuebase: stringhead: string
get_pull( number ):PullRequestnumber: integer
get_pulls( [state] ): iterator ofPullRequeststate: string
Tags
get_tags(): iterator ofTag
Teams
get_teams(): iterator ofTeam
Watchers
get_watchers(): iterator ofNamedUser
Class RepositoryKey
Attributes
id: integerkey: stringtitle: stringurl: stringverified: bool
Deletion
delete()
Modification
edit( [title, key] )title: stringkey: string
Class Tag
Attributes
commit:Commitname: stringtarball_url: stringzipball_url: string
Class Team
Attributes
id: integermembers_count: integername: stringpermission: stringrepos_count: integerurl: string
Deletion
delete()
Members
add_to_members( member )member:NamedUser
get_members(): iterator ofNamedUserhas_in_members( member ): boolmember:NamedUser
remove_from_members( member )member:NamedUser
Modification
edit( name, [permission] )name: stringpermission: string
Repos
add_to_repos( repo )repo:Repository
get_repos(): iterator ofRepositoryhas_in_repos( repo ): boolrepo:Repository
remove_from_repos( repo )repo:Repository
Class UserKey
Attributes
id: integerkey: stringtitle: stringurl: stringverified: bool
Deletion
delete()
Modification
edit( [title, key] )title: stringkey: string