Sunday, April 29, 2018

Cool Java library to handle github

Especially useful is the Authentication API, it's really very simple.

package pvgithubclient;

import com.jcabi.github.Coordinates;
import com.jcabi.github.Github;
import com.jcabi.github.Issue;
import com.jcabi.github.Repo;
import com.jcabi.github.RtGithub;

public class GitClient {
 public static void main(String[] args) throws Exception {
  Github github = new RtGithub("myusername", "mypassword");
  Repo repo = github.repos().get(new Coordinates.Simple("myusername", "myrepository"));
  Issue issue = repo.issues().create("How are you?", "Please tell me...");
     issue.comments().post("My first comment!");

Farewall to all those horrible REST calls with hand-made JSON or even worse XML.
Yes, "FareWALL" in the sense that I hope that whoever invented REST and XML and JSON can hit a WALL with his bicycle. Proper APIs is the only way to handle everything.

Ah, beware that you cannot DELETE an issue in github, once created.... this because some MORONIC FASCIST decided so, despite public outrage. So use this example with care.

No comments: