public class GitHub
extends java.lang.Object
This library aims to be safe for use by multiple threads concurrently, although the library itself makes no attempt to control/serialize potentially conflicting operations to GitHub, such as updating & deleting a repository at the same time.
| Modifier and Type | Method and Description |
|---|---|
void |
checkApiUrlValidity()
Tests the connection.
|
static GitHub |
connect()
Obtains the credential from "~/.github" or from the System Environment Properties.
|
static GitHub |
connect(java.lang.String login,
java.lang.String oauthAccessToken) |
static GitHub |
connect(java.lang.String login,
java.lang.String oauthAccessToken,
java.lang.String password)
Deprecated.
Either OAuth token or password is sufficient, so there's no point in passing both.
Use
connectUsingPassword(String, String) or connectUsingOAuth(String). |
static GitHub |
connectAnonymously()
Connects to GitHub anonymously.
|
static GitHub |
connectToEnterprise(java.lang.String apiUrl,
java.lang.String oauthAccessToken)
Version that connects to GitHub Enterprise.
|
static GitHub |
connectToEnterprise(java.lang.String apiUrl,
java.lang.String login,
java.lang.String password) |
static GitHub |
connectToEnterpriseAnonymously(java.lang.String apiUrl)
Connects to GitHub Enterprise anonymously.
|
static GitHub |
connectUsingOAuth(java.lang.String oauthAccessToken) |
static GitHub |
connectUsingOAuth(java.lang.String githubServer,
java.lang.String oauthAccessToken) |
static GitHub |
connectUsingPassword(java.lang.String login,
java.lang.String password) |
GHGistBuilder |
createGist() |
GHCreateRepositoryBuilder |
createRepository(java.lang.String name)
Starts a builder that creates a new repository.
|
GHRepository |
createRepository(java.lang.String name,
java.lang.String description,
java.lang.String homepage,
boolean isPublic)
Deprecated.
Use
createRepository(String) that uses a builder pattern to let you control every aspect. |
GHAuthorization |
createToken(java.util.Collection<java.lang.String> scope,
java.lang.String note,
java.lang.String noteUrl)
Creates a new authorization.
|
HttpConnector |
getConnector() |
java.util.List<GHEventInfo> |
getEvents()
Public events visible to you.
|
GHGist |
getGist(java.lang.String id)
Gets a sigle gist by ID.
|
GHLicense |
getLicense(java.lang.String key)
Deprecated.
|
java.util.Map<java.lang.String,GHOrganization> |
getMyOrganizations()
/**
This method returns a shallowly populated organizations.
|
GHMyself |
getMyself()
Gets the
GHUser that represents yourself. |
java.util.Map<java.lang.String,java.util.Set<GHTeam>> |
getMyTeams()
Gets complete map of organizations/teams that current user belongs to.
|
GHOrganization |
getOrganization(java.lang.String name) |
GHRateLimit |
getRateLimit()
Gets the current rate limit.
|
GHRepository |
getRepository(java.lang.String name)
Gets the repository object from 'user/reponame' string that GitHub calls as "repository name"
|
protected GHUser |
getUser(GHUser orig)
Interns the given
GHUser. |
GHUser |
getUser(java.lang.String login)
Obtains the object that represents the named user.
|
boolean |
isAnonymous()
Is this an anonymous connection
|
boolean |
isCredentialValid()
Ensures that the credential is valid.
|
PagedIterable<GHRepository> |
listAllPublicRepositories()
This provides a dump of every public repository, in the order that they were created.
|
PagedIterable<GHRepository> |
listAllPublicRepositories(java.lang.String since)
This provides a dump of every public repository, in the order that they were created.
|
PagedIterable<GHLicense> |
listLicenses()
Deprecated.
|
GHNotificationStream |
listNotifications()
List all the notifications.
|
<T extends GHEventPayload> |
parseEventPayload(java.io.Reader r,
java.lang.Class<T> type)
Parses the GitHub event object.
|
void |
refreshCache()
clears all cached data in order for external changes (modifications and del
|
java.io.Reader |
renderMarkdown(java.lang.String text)
Render a Markdown document in raw mode.
|
GHContentSearchBuilder |
searchContent()
Search content.
|
GHIssueSearchBuilder |
searchIssues()
Search issues.
|
GHRepositorySearchBuilder |
searchRepositories()
Search repositories.
|
GHUserSearchBuilder |
searchUsers()
Search users.
|
void |
setConnector(HttpConnector connector)
Sets the custom connector used to make requests to GitHub.
|
public static GitHub connect() throws java.io.IOException
java.io.IOExceptionpublic static GitHub connectToEnterprise(java.lang.String apiUrl, java.lang.String oauthAccessToken) throws java.io.IOException
apiUrl - The URL of GitHub (or GitHub enterprise) API endpoint, such as "https://api.github.com" or
"http://ghe.acme.com/api/v3". Note that GitHub Enterprise has /api/v3 in the URL.
For historical reasons, this parameter still accepts the bare domain name, but that's considered deprecated.java.io.IOExceptionpublic static GitHub connectToEnterprise(java.lang.String apiUrl, java.lang.String login, java.lang.String password) throws java.io.IOException
java.io.IOExceptionpublic static GitHub connect(java.lang.String login, java.lang.String oauthAccessToken) throws java.io.IOException
java.io.IOExceptionpublic static GitHub connect(java.lang.String login, java.lang.String oauthAccessToken, java.lang.String password) throws java.io.IOException
connectUsingPassword(String, String) or connectUsingOAuth(String).java.io.IOExceptionpublic static GitHub connectUsingPassword(java.lang.String login, java.lang.String password) throws java.io.IOException
java.io.IOExceptionpublic static GitHub connectUsingOAuth(java.lang.String oauthAccessToken) throws java.io.IOException
java.io.IOExceptionpublic static GitHub connectUsingOAuth(java.lang.String githubServer, java.lang.String oauthAccessToken) throws java.io.IOException
java.io.IOExceptionpublic static GitHub connectAnonymously() throws java.io.IOException
java.io.IOExceptionpublic static GitHub connectToEnterpriseAnonymously(java.lang.String apiUrl) throws java.io.IOException
java.io.IOExceptionpublic boolean isAnonymous()
true if operations that require authentication will fail.public HttpConnector getConnector()
public void setConnector(HttpConnector connector)
public GHRateLimit getRateLimit() throws java.io.IOException
java.io.IOException@WithBridgeMethods(value=GHUser.class) public GHMyself getMyself() throws java.io.IOException
GHUser that represents yourself.java.io.IOExceptionpublic GHUser getUser(java.lang.String login) throws java.io.IOException
java.io.IOExceptionpublic void refreshCache()
protected GHUser getUser(GHUser orig) throws java.io.IOException
GHUser.java.io.IOExceptionpublic GHOrganization getOrganization(java.lang.String name) throws java.io.IOException
java.io.IOExceptionpublic GHRepository getRepository(java.lang.String name) throws java.io.IOException
java.io.IOExceptionGHRepository.getName()@Preview @Deprecated public PagedIterable<GHLicense> listLicenses() throws java.io.IOException
java.io.IOException@Preview @Deprecated public GHLicense getLicense(java.lang.String key) throws java.io.IOException
key - The license key provided from the APIjava.io.IOExceptionGHLicense.getKey()public java.util.Map<java.lang.String,GHOrganization> getMyOrganizations() throws java.io.IOException
getOrganization(String)
TODO: make this automatic.java.io.IOExceptionpublic java.util.Map<java.lang.String,java.util.Set<GHTeam>> getMyTeams() throws java.io.IOException
java.io.IOExceptionpublic java.util.List<GHEventInfo> getEvents() throws java.io.IOException
java.io.IOExceptionpublic GHGist getGist(java.lang.String id) throws java.io.IOException
java.io.IOExceptionpublic GHGistBuilder createGist()
public <T extends GHEventPayload> T parseEventPayload(java.io.Reader r, java.lang.Class<T> type) throws java.io.IOException
java.io.IOExceptionpublic GHRepository createRepository(java.lang.String name, java.lang.String description, java.lang.String homepage, boolean isPublic) throws java.io.IOException
createRepository(String) that uses a builder pattern to let you control every aspect.java.io.IOExceptionpublic GHCreateRepositoryBuilder createRepository(java.lang.String name)
You use the returned builder to set various properties, then call GHCreateRepositoryBuilder.create()
to finally createa repository.
To create a repository in an organization, see
GHOrganization.createRepository(String, String, String, GHTeam, boolean)
public GHAuthorization createToken(java.util.Collection<java.lang.String> scope, java.lang.String note, java.lang.String noteUrl) throws java.io.IOException
connectUsingOAuth(String) in the future.java.io.IOExceptionpublic boolean isCredentialValid()
throws java.io.IOException
java.io.IOExceptionpublic void checkApiUrlValidity()
throws java.io.IOException
Verify that the API URL and credentials are valid to access this GitHub.
This method returns normally if the endpoint is reachable and verified to be GitHub API URL.
Otherwise this method throws IOException to indicate the problem.
java.io.IOExceptionpublic GHIssueSearchBuilder searchIssues()
public GHUserSearchBuilder searchUsers()
public GHRepositorySearchBuilder searchRepositories()
public GHContentSearchBuilder searchContent()
public GHNotificationStream listNotifications()
public PagedIterable<GHRepository> listAllPublicRepositories()
public PagedIterable<GHRepository> listAllPublicRepositories(java.lang.String since)
since - The integer ID of the last Repository that you’ve seen. See GHObject.getId()public java.io.Reader renderMarkdown(java.lang.String text)
throws java.io.IOException
It takes a Markdown document as plaintext and renders it as plain Markdown without a repository context (just like a README.md file is rendered – this is the simplest way to preview a readme online).
java.io.IOExceptionGHRepository.renderMarkdown(String, MarkdownMode)Copyright © 2016. All Rights Reserved.