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 apiToken)
           
static GitHub connect(String login, String apiToken, String password)
           
static GitHub connectAnonymously()
          Connects to GitHub anonymously.
static GitHub connectUsingOAuth(String accessToken)
           
static GitHub connectUsingOAuth(String githubServer, String accessToken)
           
 GHRepository createRepository(String name, String description, String homepage, boolean isPublic)
          Creates a new repository.
 List<GHEventInfo> getEvents()
          Public events visible to you.
 Map<String,GHOrganization> getMyOrganizations()
           
 GHMyself getMyself()
          Gets the GHUser that represents yourself.
 GHOrganization getOrganization(String name)
           
 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

connect

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

connect

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

connectUsingOAuth

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

connectUsingOAuth

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

connectAnonymously

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


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
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

isCredentialValid

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

Throws:
IOException


Copyright © 2012. All Rights Reserved.