org.kohsuke.github
Class GitHub

java.lang.Object
  extended by org.kohsuke.github.GitHub

public class GitHub
extends Object

Root of the GitHub API.

Author:
Kohsuke Kawaguchi

Method Summary
static GitHub connect()
          Obtains the credential from "~/.github"
static GitHub connect(String login, String oauthAccessToken)
           
static GitHub connect(String login, String oauthAccessToken, 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(String apiUrl, String oauthAccessToken)
          Version that connects to GitHub Enterprise.
static GitHub connectToEnterprise(String apiUrl, String login, String password)
           
static GitHub connectUsingOAuth(String oauthAccessToken)
           
static GitHub connectUsingOAuth(String githubServer, String oauthAccessToken)
           
static GitHub connectUsingPassword(String login, String password)
           
 GHRepository createRepository(String name, String description, String homepage, boolean isPublic)
          Creates a new repository.
 GHAuthorization createToken(Collection<String> scope, String note, String noteUrl)
          Creates a new authorization.
 List<GHEventInfo> getEvents()
          Public events visible to you.
 Map<String,GHOrganization> getMyOrganizations()
          This method returns a shallowly populated organizations.
 GHMyself getMyself()
          Gets the GHUser that represents yourself.
 GHOrganization getOrganization(String name)
           
 GHRateLimit getRateLimit()
          Gets the current rate limit.
 GHRepository getRepository(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(String login)
          Obtains the object that represents the named user.
 boolean isCredentialValid()
          Ensures that the credential is valid.
<T extends GHEventPayload>
T
parseEventPayload(Reader r, Class<T> type)
          Parses the GitHub event object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

connect

public static GitHub connect()
                      throws IOException
Obtains the credential from "~/.github"

Throws:
IOException

connectToEnterprise

public static GitHub connectToEnterprise(String apiUrl,
                                         String oauthAccessToken)
                                  throws IOException
Version that connects to GitHub Enterprise.

Parameters:
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.
Throws:
IOException

connectToEnterprise

public static GitHub connectToEnterprise(String apiUrl,
                                         String login,
                                         String password)
                                  throws IOException
Throws:
IOException

connect

public static GitHub connect(String login,
                             String oauthAccessToken)
                      throws IOException
Throws:
IOException

connect

public static GitHub connect(String login,
                             String oauthAccessToken,
                             String password)
                      throws IOException
Deprecated. Either OAuth token or password is sufficient, so there's no point in passing both. Use connectUsingPassword(String, String) or connectUsingOAuth(String).

Throws:
IOException

connectUsingPassword

public static GitHub connectUsingPassword(String login,
                                          String password)
                                   throws IOException
Throws:
IOException

connectUsingOAuth

public static GitHub connectUsingOAuth(String oauthAccessToken)
                                throws IOException
Throws:
IOException

connectUsingOAuth

public static GitHub connectUsingOAuth(String githubServer,
                                       String oauthAccessToken)
                                throws IOException
Throws:
IOException

connectAnonymously

public static GitHub connectAnonymously()
                                 throws IOException
Connects to GitHub anonymously. All operations that requires authentication will fail.

Throws:
IOException

getRateLimit

public GHRateLimit getRateLimit()
                         throws IOException
Gets the current rate limit.

Throws:
IOException

getMyself

@WithBridgeMethods(value=GHUser.class)
public GHMyself getMyself()
                   throws IOException
Gets the GHUser that represents yourself.

Throws:
IOException

getUser

public GHUser getUser(String login)
               throws IOException
Obtains the object that represents the named user.

Throws:
IOException

getUser

protected GHUser getUser(GHUser orig)
                  throws IOException
Interns the given GHUser.

Throws:
IOException

getOrganization

public GHOrganization getOrganization(String name)
                               throws IOException
Throws:
IOException

getRepository

public GHRepository getRepository(String name)
                           throws IOException
Gets the repository object from 'user/reponame' string that GitHub calls as "repository name"

Throws:
IOException
See Also:
GHRepository.getName()

getMyOrganizations

public Map<String,GHOrganization> getMyOrganizations()
                                              throws IOException
This method returns a shallowly populated organizations. To retrieve full organization details, you need to call getOrganization(String) TODO: make this automatic.

Throws:
IOException

getEvents

public List<GHEventInfo> getEvents()
                            throws IOException
Public events visible to you. Equivalent of what's displayed on https://github.com/

Throws:
IOException

parseEventPayload

public <T extends GHEventPayload> T parseEventPayload(Reader r,
                                                      Class<T> type)
                                           throws IOException
Parses the GitHub event object. This is primarily intended for receiving a POST HTTP call from a hook. Unfortunately, hook script payloads aren't self-descriptive, so you need to know the type of the payload you are expecting.

Throws:
IOException

createRepository

public GHRepository createRepository(String name,
                                     String description,
                                     String homepage,
                                     boolean isPublic)
                              throws IOException
Creates a new repository.

Returns:
Newly created repository.
Throws:
IOException

createToken

public GHAuthorization createToken(Collection<String> scope,
                                   String note,
                                   String noteUrl)
                            throws IOException
Creates a new authorization. The token created can be then used for connectUsingOAuth(String) in the future.

Throws:
IOException
See Also:
Documentation

isCredentialValid

public boolean isCredentialValid()
                          throws IOException
Ensures that the credential is valid.

Throws:
IOException


Copyright © 2013. All rights reserved.