66
77# github-client
88
9- A small Java library for talking to Github/Github Enterprise and interacting with projects.
9+ A small Java library for talking to GitHub/GitHub Enterprise and interacting with projects.
1010
11- It supports authentication via simple access tokens, JWT endpoints and Github Apps (via private key).
11+ It supports authentication via simple access tokens, JWT endpoints and GitHub Apps (via private key).
1212
1313It is also very light on GitHub, doing as few requests as necessary.
1414
@@ -25,10 +25,10 @@ In Maven:
2525</dependency >
2626```
2727
28- Start talking to Github API.
28+ Start talking to GitHub API.
2929
3030``` java
31- final GitHubClient github = GitHubClient . create(URI . create(" https://github.com/api/v3 /" ));
31+ final GitHubClient github = GitHubClient . create(URI . create(" https://api. github.com/" ));
3232final IssueApi issueClient = github. createRepositoryClient(" my-org" , " my-repo" ). createIssueClient();
3333issueClient. listComments(ISSUE_ID ). get(). forEach(comment - > log. info(comment. body()));
3434```
@@ -38,19 +38,19 @@ issueClient.listComments(ISSUE_ID).get().forEach(comment -> log.info(comment.bod
3838### Simple access token
3939
4040``` java
41- final GitHubClient github = GitHubClient . create(URI . create(" https://github.com/api/v3 /" ), " my-access-token" );
41+ final GitHubClient github = GitHubClient . create(URI . create(" https://api. github.com/" ), " my-access-token" );
4242// Do the requests
4343github. createRepositoryClient(" my-org" , " my-repo" ). getCommit(" sha" );
4444```
4545
4646### Private key
4747
48- To authenticate as a Github App, you must provide a private key and the App ID, together with the API URL.
48+ To authenticate as a GitHub App, you must provide a private key and the App ID, together with the API URL.
4949
5050``` java
5151final GitHubClient github =
5252 GitHubClient . create(
53- URI . create(" https://github.com/api/v3 /" ),
53+ URI . create(" https://api. github.com/" ),
5454 new File (" /path-to-the/private-key.pem" ),
5555 APP_ID );
5656```
@@ -67,15 +67,15 @@ scoped.createRepositoryClient("my-org", "my-repo").getCommit("sha");
6767
6868It is also possible to provide the installation to the root client.
6969
70- Refer to [ Github App Authentication Guide] ( https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/ ) for more information.
70+ Refer to [ GitHub App Authentication Guide] ( https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/ ) for more information.
7171
7272## Usage
7373
7474This library attempts to mirror the structure of GitHub API endpoints. As an example, to get details of a Commit, there is
7575the ` GET /repos/:owner/:repo/commits ` API call, under the ` repos ` API. Therefore, the ` getCommit ` method lives in the RepositoryClient.
7676
7777``` java
78- final GitHubClient github = GitHubClient . create(URI . create(" https://github.com/api/v3 /" ), " my-access-token" );
78+ final GitHubClient github = GitHubClient . create(URI . create(" https://api. github.com/" ), " my-access-token" );
7979github. createRepositoryClient(" my-org" , " my-repo" ). getCommit(" sha" );
8080```
8181
@@ -84,10 +84,10 @@ Some APIs, such as Checks API are nested in the Repository API. Endpoints such a
8484``` java
8585final GitHubClient github =
8686 GitHubClient . create(
87- URI . create(" https://github.com/api/v3 /" ),
87+ URI . create(" https://api. github.com/" ),
8888 new File (" /path-to-the/private-key.der" ),
8989 APP_ID );
90- // Checks API need to be used by Github Apps
90+ // Checks API need to be used by GitHub Apps
9191GitHubClient . scopeForInstallationId(github, INSTALLATION_ID )
9292 .createRepositoryClient(" my-org" , " my-repo" )
9393 .createChecksApiClient()
@@ -106,8 +106,8 @@ mvn clean verify
106106
107107This module was created after existing libraries were evaluated and dismissed, and we found that we were writing similar
108108code in multiple projects. As such, it at least initially only contains enough functionality for our internal requirements
109- which reflect that we were working on build system integration with the Github pull requests. It has been widely used for 4+
110- years. It's important to notice that it does not cover all Github v3 API. Adding missing endpoints should be very straightforward.
109+ which reflect that we were working on build system integration with the GitHub pull requests. It has been widely used for 4+
110+ years. It's important to notice that it does not cover all GitHub v3 API. Adding missing endpoints should be very straightforward.
111111Pull Requests are welcome.
112112
113113## Code of conduct
0 commit comments