6
6
7
7
# github-client
8
8
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.
10
10
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).
12
12
13
13
It is also very light on GitHub, doing as few requests as necessary.
14
14
@@ -25,10 +25,10 @@ In Maven:
25
25
</dependency >
26
26
```
27
27
28
- Start talking to Github API.
28
+ Start talking to GitHub API.
29
29
30
30
``` 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/" ));
32
32
final IssueApi issueClient = github. createRepositoryClient(" my-org" , " my-repo" ). createIssueClient();
33
33
issueClient. listComments(ISSUE_ID ). get(). forEach(comment - > log. info(comment. body()));
34
34
```
@@ -38,19 +38,19 @@ issueClient.listComments(ISSUE_ID).get().forEach(comment -> log.info(comment.bod
38
38
### Simple access token
39
39
40
40
``` 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" );
42
42
// Do the requests
43
43
github. createRepositoryClient(" my-org" , " my-repo" ). getCommit(" sha" );
44
44
```
45
45
46
46
### Private key
47
47
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.
49
49
50
50
``` java
51
51
final GitHubClient github =
52
52
GitHubClient . create(
53
- URI . create(" https://github.com/api/v3 /" ),
53
+ URI . create(" https://api. github.com/" ),
54
54
new File (" /path-to-the/private-key.pem" ),
55
55
APP_ID );
56
56
```
@@ -67,15 +67,15 @@ scoped.createRepositoryClient("my-org", "my-repo").getCommit("sha");
67
67
68
68
It is also possible to provide the installation to the root client.
69
69
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.
71
71
72
72
## Usage
73
73
74
74
This library attempts to mirror the structure of GitHub API endpoints. As an example, to get details of a Commit, there is
75
75
the ` GET /repos/:owner/:repo/commits ` API call, under the ` repos ` API. Therefore, the ` getCommit ` method lives in the RepositoryClient.
76
76
77
77
``` 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" );
79
79
github. createRepositoryClient(" my-org" , " my-repo" ). getCommit(" sha" );
80
80
```
81
81
@@ -84,10 +84,10 @@ Some APIs, such as Checks API are nested in the Repository API. Endpoints such a
84
84
``` java
85
85
final GitHubClient github =
86
86
GitHubClient . create(
87
- URI . create(" https://github.com/api/v3 /" ),
87
+ URI . create(" https://api. github.com/" ),
88
88
new File (" /path-to-the/private-key.der" ),
89
89
APP_ID );
90
- // Checks API need to be used by Github Apps
90
+ // Checks API need to be used by GitHub Apps
91
91
GitHubClient . scopeForInstallationId(github, INSTALLATION_ID )
92
92
.createRepositoryClient(" my-org" , " my-repo" )
93
93
.createChecksApiClient()
@@ -106,8 +106,8 @@ mvn clean verify
106
106
107
107
This module was created after existing libraries were evaluated and dismissed, and we found that we were writing similar
108
108
code 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.
111
111
Pull Requests are welcome.
112
112
113
113
## Code of conduct
0 commit comments