Skip to content

Commit a5a9b6b

Browse files
committed
Merge tag 'github-api-2.0-alpha-3' into release/v2.x
github-api-2.0-alpha-3
2 parents 9fae181 + fd85f91 commit a5a9b6b

File tree

179 files changed

+14455
-82
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+14455
-82
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
steps:
4444
- name: Set up JDK
45-
uses: actions/setup-java@v2
45+
uses: actions/setup-java@v4
4646
with:
4747
distribution: 'temurin'
4848
java-version: 17

.github/workflows/maven-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
name: maven-test-target-directory
108108
path: target
109109
- name: Codecov Report
110-
uses: codecov/codecov-action@v4.5.0
110+
uses: codecov/codecov-action@v5.1.2
111111
with:
112112
# Codecov token from https://app.codecov.io/gh/hub4j/github-api/settings
113113
token: ${{ secrets.CODECOV_TOKEN }}

pom.xml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.kohsuke</groupId>
44
<artifactId>github-api</artifactId>
5-
<version>2.0.0-alpha-2</version>
5+
<version>2.0-alpha-3</version>
66
<name>GitHub API for Java</name>
77
<url>https://github-api.kohsuke.org/</url>
88
<description>GitHub API for Java</description>
@@ -32,14 +32,14 @@
3232
</distributionManagement>
3333

3434
<properties>
35-
<spring.boot.version>3.3.3</spring.boot.version>
35+
<spring.boot.version>3.3.5</spring.boot.version>
3636
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37-
<spotbugs-maven-plugin.version>4.8.6.3</spotbugs-maven-plugin.version>
37+
<spotbugs-maven-plugin.version>4.8.6.4</spotbugs-maven-plugin.version>
3838
<spotbugs.version>4.8.6</spotbugs.version>
3939
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
4040
<hamcrest.version>3.0</hamcrest.version>
4141
<okhttp3.version>4.12.0</okhttp3.version>
42-
<okio.version>3.9.0</okio.version>
42+
<okio.version>3.9.1</okio.version>
4343
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
4444
<jacoco.coverage.target.bundle.method>0.70</jacoco.coverage.target.bundle.method>
4545
<jacoco.coverage.target.class.method>0.50</jacoco.coverage.target.class.method>
@@ -77,16 +77,16 @@
7777
<plugin>
7878
<groupId>org.codehaus.mojo</groupId>
7979
<artifactId>versions-maven-plugin</artifactId>
80-
<version>2.17.1</version>
80+
<version>2.18.0</version>
8181
</plugin>
8282
<plugin>
8383
<groupId>org.apache.maven.plugins</groupId>
8484
<artifactId>maven-help-plugin</artifactId>
85-
<version>3.5.0</version>
85+
<version>3.5.1</version>
8686
</plugin>
8787
<plugin>
8888
<artifactId>maven-surefire-plugin</artifactId>
89-
<version>3.5.0</version>
89+
<version>3.5.2</version>
9090
<configuration>
9191
<!-- SUREFIRE-1226 workaround -->
9292
<trimStackTrace>false</trimStackTrace>
@@ -100,7 +100,7 @@
100100
<plugin>
101101
<groupId>org.apache.maven.plugins</groupId>
102102
<artifactId>maven-gpg-plugin</artifactId>
103-
<version>3.2.6</version>
103+
<version>3.2.7</version>
104104
</plugin>
105105
<plugin>
106106
<groupId>org.jacoco</groupId>
@@ -202,7 +202,7 @@
202202
<plugin>
203203
<groupId>org.apache.maven.plugins</groupId>
204204
<artifactId>maven-javadoc-plugin</artifactId>
205-
<version>3.10.0</version>
205+
<version>3.11.1</version>
206206
<configuration>
207207
<source>11</source>
208208
<release>11</release>
@@ -245,7 +245,7 @@
245245
<plugin>
246246
<groupId>org.apache.maven.plugins</groupId>
247247
<artifactId>maven-site-plugin</artifactId>
248-
<version>3.12.1</version>
248+
<version>3.21.0</version>
249249
</plugin>
250250
<plugin>
251251
<groupId>org.apache.maven.plugins</groupId>
@@ -265,7 +265,7 @@
265265
<plugin>
266266
<groupId>org.apache.maven.plugins</groupId>
267267
<artifactId>maven-project-info-reports-plugin</artifactId>
268-
<version>3.7.0</version>
268+
<version>3.8.0</version>
269269
<dependencies>
270270
<dependency>
271271
<groupId>org.apache.bcel</groupId>
@@ -419,7 +419,7 @@
419419
<dependency>
420420
<groupId>com.fasterxml.jackson</groupId>
421421
<artifactId>jackson-bom</artifactId>
422-
<version>2.17.2</version>
422+
<version>2.18.2</version>
423423
<scope>import</scope>
424424
<type>pom</type>
425425
</dependency>
@@ -504,13 +504,13 @@
504504
<dependency>
505505
<groupId>com.infradna.tool</groupId>
506506
<artifactId>bridge-method-annotation</artifactId>
507-
<version>1.29</version>
507+
<version>1.30</version>
508508
<optional>true</optional>
509509
</dependency>
510510
<dependency>
511511
<groupId>com.google.guava</groupId>
512512
<artifactId>guava</artifactId>
513-
<version>33.1.0-jre</version>
513+
<version>33.4.0-jre</version>
514514
<scope>test</scope>
515515
</dependency>
516516
<dependency>
@@ -552,7 +552,7 @@
552552
<dependency>
553553
<groupId>org.mockito</groupId>
554554
<artifactId>mockito-core</artifactId>
555-
<version>5.13.0</version>
555+
<version>5.14.2</version>
556556
<scope>test</scope>
557557
</dependency>
558558
<dependency>

src/main/java/org/kohsuke/github/GHApp.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,22 @@ public Map<String, String> getPermissions() {
120120
return Collections.unmodifiableMap(permissions);
121121
}
122122

123+
/**
124+
* Obtains all the installation requests associated with this app.
125+
* <p>
126+
* You must use a JWT to access this endpoint.
127+
*
128+
* @return a list of App installation requests
129+
* @see <a href=
130+
* "https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#list-installation-requests-for-the-authenticated-app">List
131+
* installation requests</a>
132+
*/
133+
public PagedIterable<GHAppInstallationRequest> listInstallationRequests() {
134+
return root().createRequest()
135+
.withUrlPath("/app/installation-requests")
136+
.toIterable(GHAppInstallationRequest[].class, null);
137+
}
138+
123139
/**
124140
* Obtains all the installations associated with this app.
125141
* <p>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.kohsuke.github;
2+
3+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4+
5+
/**
6+
* A Github App Installation Request.
7+
*
8+
* @author Anuj Hydrabadi
9+
* @see GHApp#listInstallationRequests() GHApp#listInstallationRequests()
10+
*/
11+
public class GHAppInstallationRequest extends GHObject {
12+
/**
13+
* Create default GHAppInstallationRequest instance
14+
*/
15+
public GHAppInstallationRequest() {
16+
}
17+
18+
private GHOrganization account;
19+
20+
private GHUser requester;
21+
22+
/**
23+
* Gets the organization where the app was requested to be installed.
24+
*
25+
* @return the organization where the app was requested to be installed.
26+
*/
27+
@SuppressFBWarnings(value = { "EI_EXPOSE_REP", "UWF_UNWRITTEN_FIELD" }, justification = "Expected behavior")
28+
public GHOrganization getAccount() {
29+
return account;
30+
}
31+
32+
/**
33+
* Gets the user who requested the installation.
34+
*
35+
* @return the user who requested the installation.
36+
*/
37+
@SuppressFBWarnings(value = { "EI_EXPOSE_REP", "UWF_UNWRITTEN_FIELD" }, justification = "Expected behavior")
38+
public GHUser getRequester() {
39+
return requester;
40+
}
41+
42+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package org.kohsuke.github;
2+
3+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4+
5+
import java.io.IOException;
6+
7+
/**
8+
* Represents a GitHub repository autolink reference.
9+
*
10+
* @author Alaurant
11+
* @see GHAutolinkBuilder
12+
* @see GHRepository#listAutolinks() GHRepository#listAutolinks()
13+
* @see <a href="https://docs.github.com/en/rest/repos/autolinks">Repository autolinks API</a>
14+
*/
15+
public class GHAutolink {
16+
17+
private int id;
18+
private String key_prefix;
19+
private String url_template;
20+
private boolean is_alphanumeric;
21+
private GHRepository owner;
22+
23+
/**
24+
* Instantiates a new Gh autolink.
25+
*/
26+
public GHAutolink() {
27+
}
28+
29+
/**
30+
* Gets the autolink ID
31+
*
32+
* @return the id
33+
*/
34+
public int getId() {
35+
return id;
36+
}
37+
38+
/**
39+
* Gets the key prefix used to identify issues/PR references
40+
*
41+
* @return the key prefix string
42+
*/
43+
public String getKeyPrefix() {
44+
return key_prefix;
45+
}
46+
47+
/**
48+
* Gets the URL template that will be used for matching
49+
*
50+
* @return the URL template string
51+
*/
52+
public String getUrlTemplate() {
53+
return url_template;
54+
}
55+
56+
/**
57+
* Checks if the autolink uses alphanumeric values
58+
*
59+
* @return true if alphanumeric, false otherwise
60+
*/
61+
public boolean isAlphanumeric() {
62+
return is_alphanumeric;
63+
}
64+
65+
/**
66+
* Gets the repository that owns this autolink
67+
*
68+
* @return the repository instance
69+
*/
70+
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
71+
public GHRepository getOwner() {
72+
return owner;
73+
}
74+
75+
/**
76+
* Deletes this autolink
77+
*
78+
* @throws IOException
79+
* if the deletion fails
80+
*/
81+
public void delete() throws IOException {
82+
owner.root()
83+
.createRequest()
84+
.method("DELETE")
85+
.withUrlPath(String.format("/repos/%s/%s/autolinks/%d", owner.getOwnerName(), owner.getName(), getId()))
86+
.send();
87+
}
88+
89+
/**
90+
* Wraps this autolink with its owner repository.
91+
*
92+
* @param owner
93+
* the repository that owns this autolink
94+
* @return this instance
95+
*/
96+
GHAutolink lateBind(GHRepository owner) {
97+
this.owner = owner;
98+
return this;
99+
}
100+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package org.kohsuke.github;
2+
3+
import java.io.IOException;
4+
5+
// TODO: Auto-generated Javadoc
6+
/**
7+
* The type Gh autolink builder.
8+
*
9+
* @see GHRepository#createAutolink()
10+
* @see GHAutolink
11+
*/
12+
public class GHAutolinkBuilder {
13+
14+
private final GHRepository repo;
15+
private final Requester req;
16+
private String keyPrefix;
17+
private String urlTemplate;
18+
private Boolean isAlphanumeric;
19+
20+
/**
21+
* Instantiates a new Gh autolink builder.
22+
*
23+
* @param repo
24+
* the repo
25+
*/
26+
GHAutolinkBuilder(GHRepository repo) {
27+
this.repo = repo;
28+
req = repo.root().createRequest();
29+
}
30+
31+
/**
32+
* With key prefix gh autolink builder.
33+
*
34+
* @param keyPrefix
35+
* the key prefix
36+
* @return the gh autolink builder
37+
*/
38+
public GHAutolinkBuilder withKeyPrefix(String keyPrefix) {
39+
this.keyPrefix = keyPrefix;
40+
return this;
41+
}
42+
43+
/**
44+
* With url template gh autolink builder.
45+
*
46+
* @param urlTemplate
47+
* the url template
48+
* @return the gh autolink builder
49+
*/
50+
public GHAutolinkBuilder withUrlTemplate(String urlTemplate) {
51+
this.urlTemplate = urlTemplate;
52+
return this;
53+
}
54+
55+
/**
56+
* With is alphanumeric gh autolink builder.
57+
*
58+
* @param isAlphanumeric
59+
* the is alphanumeric
60+
* @return the gh autolink builder
61+
*/
62+
public GHAutolinkBuilder withIsAlphanumeric(boolean isAlphanumeric) {
63+
this.isAlphanumeric = isAlphanumeric;
64+
return this;
65+
}
66+
67+
private String getApiTail() {
68+
return String.format("/repos/%s/%s/autolinks", repo.getOwnerName(), repo.getName());
69+
}
70+
71+
/**
72+
* Create gh autolink.
73+
*
74+
* @return the gh autolink
75+
* @throws IOException
76+
* the io exception
77+
*/
78+
public GHAutolink create() throws IOException {
79+
GHAutolink autolink = req.method("POST")
80+
.with("key_prefix", keyPrefix)
81+
.with("url_template", urlTemplate)
82+
.with("is_alphanumeric", isAlphanumeric)
83+
.withHeader("Accept", "application/vnd.github+json")
84+
.withUrlPath(getApiTail())
85+
.fetch(GHAutolink.class);
86+
87+
return autolink.lateBind(repo);
88+
}
89+
90+
}

0 commit comments

Comments
 (0)