jcabi-github

Object Oriented Github API

License

License

BSD
Categories

Categories

Github Development Tools Version Controls
GroupId

GroupId

com.jcabi
ArtifactId

ArtifactId

jcabi-github
Last Version

Last Version

1.1.2
Release Date

Release Date

Type

Type

jar
Description

Description

jcabi-github
Object Oriented Github API
Project Organization

Project Organization

jcabi.com
Source Code Management

Source Code Management

https://github.com/jcabi/jcabi-github

Download jcabi-github

How to add to project

<!-- https://jarcasting.com/artifacts/com.jcabi/jcabi-github/ -->
<dependency>
    <groupId>com.jcabi</groupId>
    <artifactId>jcabi-github</artifactId>
    <version>1.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.jcabi/jcabi-github/
implementation 'com.jcabi:jcabi-github:1.1.2'
// https://jarcasting.com/artifacts/com.jcabi/jcabi-github/
implementation ("com.jcabi:jcabi-github:1.1.2")
'com.jcabi:jcabi-github:jar:1.1.2'
<dependency org="com.jcabi" name="jcabi-github" rev="1.1.2">
  <artifact name="jcabi-github" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.jcabi', module='jcabi-github', version='1.1.2')
)
libraryDependencies += "com.jcabi" % "jcabi-github" % "1.1.2"
[com.jcabi/jcabi-github "1.1.2"]

Dependencies

compile (11)

Group / Artifact Type Version
com.jcabi : jcabi-aspects jar 0.22.5
com.jcabi : jcabi-immutable jar 1.4
com.jcabi : jcabi-xml jar 0.18.1
com.jcabi : jcabi-http jar 1.16
com.jcabi.incubator : xembly jar 0.22
com.jcabi : jcabi-log jar 0.17.2
commons-io : commons-io jar 2.4
org.apache.commons : commons-lang3 jar 3.4
org.hamcrest : hamcrest-library jar 1.3
org.hamcrest : hamcrest-core jar 1.3
com.google.guava : guava jar 20.0

provided (5)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.16.18
javax.ws.rs : jsr311-api jar 1.1.1
javax.json : javax.json-api jar 1.1
javax.servlet : servlet-api jar 3.0-alpha-1
xml-apis : xml-apis jar 1.4.01

runtime (5)

Group / Artifact Type Version
org.aspectj : aspectjrt jar 1.8.11
org.glassfish : javax.json jar 1.1
org.glassfish.jersey.core : jersey-server jar 2.17
org.apache.httpcomponents : httpcore jar 4.4.6
org.apache.httpcomponents : httpclient jar 4.5.3

test (8)

Group / Artifact Type Version
commons-collections : commons-collections jar 3.2.1
junit : junit jar 4.12
commons-codec : commons-codec jar 1.10
org.reflections : reflections jar 0.9.10
javax.validation : validation-api jar 2.0.0.Final
xerces : xercesImpl jar 2.11.0
com.sun.grizzly : grizzly-servlet-webserver jar 1.9.64
com.jcraft : jsch jar 0.1.54

Project Modules

There are no modules declared in this project.

Donate via Zerocracy

EO principles respected here Managed by Zerocracy DevOps By Rultor.com We recommend IntelliJ IDEA

Build Status Build status PDD status jpeek report Hits-of-Code

Maven Central JavaDoc

This is a Java adapter to the GitHub RESTful API. There are a few other similar implementations on the market, but jcabi-github has a very strong focus on object-oriented principles of programming. On top of that, we have a unique implemenation of GitHub server-side functionality, which you can use in your unit tests, eliminating the necessity to connect to GitHub during unit/integration testing. Please, read the blog post Object-Oriented Github API by Yegor Bugayenko, the creator of this library.

Java 8 or higher is required.

More details are here: github.jcabi.com.

You may also get help in this Telegram chat.

The set of classes in the com.jcabi.github package is the object-oriented API. Use it like this:

Work with Github's API

By default, the library works with Github's API (https://api.github.com)

import com.jcabi.github.*;
public class Main {
  public static void main(String[] args) throws IOException {
    Github github = new RtGithub(".. your OAuth token ..");
    Repo repo = github.repos().get(
        new Coordinates.Simple("octocat/Hello-World")
    );
    Issue issue = repo.issues().create("Test title", "Test description");
    issue.comments().post("My first comment!");
  }
}

Work with Github Enterprise or other

If you want to work with Github's API through another domain, you can use the URI-constructors of class RtGithub. For instance, if you have your own instance of Github deployed under the domain https://github.mydomain.com, do the following:

final Github github = new RtGithub(URI.create("https://github.mydomain.com"));

//OR

final Github github = new RtGithub(
    "<<oauth2_token>>",
    URI.create("https://github.mydomain.com")
);

//OR

final Github github = new RtGithub(
    "username", "password",
    URI.create("https://github.mydomain.com")
);

DO NOT change or mask your URIs! Using Github under a different domain is fine but do not change the URI paths. Changing the requests' paths is not possible since the whole architecture of this library relies on Github's URI paths.

For more complex configurations, you can instantiate RtGithub with your own custom Request, by using the RtGithub(Request) constructor. Be sure to configure the Request properly. See how the default Request is created -- you basically have to do the same thing.

Mock Implementation Of The API

We also provide MkGithub, a mock version of the GitHub server, which you can use in your unit tests, for example:

import com.jcabi.github.*;
public class FooTest {
  public void submitsCommentToGithubIssue() {
    final Repo repo = new MkGithub().repos().create(
      Json.createObjectBuilder().add("name", "test").build()
    );
    final Issue issue = repo.issues().create("how are you?", "");
    new Foo(issue).doSomething(); // should post a message to the issue
    MasterAssert.assertThat(
      issue.comments().iterate(),
      Matchers.iterableWithSize(1)
    );
  }
}

How to contribute?

Fork the repository, make changes, submit a pull request. We promise to review your changes same day and apply to the master branch, if they look correct.

Please run Maven (3.1 or higher!) build before submitting a pull request:

$ mvn clean install -Pqulice

There are many integration tests that check our classes against live Github accounts. In order to run them, you should create a new Github OAuth access tokens (how?), and provide them in command line, like this:

$ mvn clean install -Dit.test=RtGistITCase -Dfailsafe.github.key=<token> -Dfailsafe.github.key.second=<second-token> -Dfailsafe.github.repo=<repo>

Replace <token> and <second-token> with the OAuth access tokens of two different Github accounts. This test case will try to fork a gist from first account into second. Replace <repo> with the name of repository you create in your first account (for test purposes only), for example yegor256/test. OAuth access tokens should have permissions in their respective repos to all scopes needed by the integration test suite you want to run (including delete_repo, which is not set by default!).

Please note that different integration tests may need keys with permissions to different scopes. To run all integration tests, the key should have the following OAuth scopes:

  • read:org
  • repo
  • delete_repo
  • admin:public_key
  • gist
  • admin:repo_hook
  • user
  • user:email

RtForksITCase requires additional parameter -Dfailsafe.github.organization=<organization> where <organization> is an organization name to fork test github repository.

In order to run static analysis checks only use this:

$ mvn clean install -DskipTests -Dinvoker.skip=true -Pqulice
com.jcabi

jcabi.com

Small java components

Versions

Version
1.1.2
1.1.1
1.1
1.0
0.41
0.40
0.39
0.38
0.37
0.36.1
0.36
0.35
0.34
0.33.1
0.33
0.32
0.31
0.30
0.29
0.28
0.27
0.26
0.25
0.24
0.23
0.22.1
0.22
0.21.4
0.21.3
0.21.2
0.21.1
0.21
0.20
0.19
0.18.10
0.18.9
0.18.8
0.18.7
0.18.6
0.18.5
0.18.3
0.18.2
0.18.1
0.18
0.17
0.16
0.15.2
0.15.1
0.15
0.14
0.13.2
0.13.1
0.13
0.12.1
0.12
0.11.1
0.11
0.10
0.9.4
0.9.3
0.9.2
0.9.1
0.9
0.8.1
0.8
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7
0.6.1
0.6
0.5
0.4
0.3
0.2
0.1