Skip to content

Commit 33c39f3

Browse files
List app installation requests endpoint (#2012)
Co-authored-by: Liam Newman <[email protected]>
1 parent d37839b commit 33c39f3

File tree

8 files changed

+253
-1
lines changed

8 files changed

+253
-1
lines changed

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

+16
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>
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+
}

src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@
119119
{
120120
"name": "org.kohsuke.github.GHAppInstallationsPage"
121121
},
122+
{
123+
"name": "org.kohsuke.github.GHAppInstallationRequest"
124+
},
122125
{
123126
"name": "org.kohsuke.github.GHAppInstallationToken"
124127
},
@@ -1340,4 +1343,4 @@
13401343
{
13411344
"name": "org.kohsuke.github.SkipFromToString"
13421345
}
1343-
]
1346+
]

src/test/java/org/kohsuke/github/GHAppTest.java

+22
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,28 @@ public void getGitHubApp() throws IOException {
6969
assertThat(app.getInstallationsCount(), is((long) 1));
7070
}
7171

72+
/**
73+
* List installation requests.
74+
*
75+
* @throws IOException
76+
* Signals that an I/O exception has occurred.
77+
*/
78+
@Test
79+
public void listInstallationRequests() throws IOException {
80+
GHApp app = gitHub.getApp();
81+
List<GHAppInstallationRequest> installations = app.listInstallationRequests().toList();
82+
assertThat(installations.size(), is(1));
83+
84+
GHAppInstallationRequest appInstallation = installations.get(0);
85+
assertThat(appInstallation.getId(), is((long) 1037204));
86+
assertThat(appInstallation.getAccount().getId(), is((long) 195438329));
87+
assertThat(appInstallation.getAccount().getLogin(), is("approval-test"));
88+
assertThat(appInstallation.getRequester().getId(), is((long) 195437694));
89+
assertThat(appInstallation.getRequester().getLogin(), is("kaladinstormblessed2"));
90+
assertThat(appInstallation.getCreatedAt(), is(GitHubClient.parseDate("2025-01-17T15:50:51Z")));
91+
assertThat(appInstallation.getNodeId(), is("MDMwOkludGVncmF0aW9uSW5zdGFsbGF0aW9uUmVxdWVzdDEwMzcyMDQ="));
92+
}
93+
7294
/**
7395
* List installations.
7496
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"id": 986532,
3+
"client_id": "Iv23liTxF5NAu46u9qto",
4+
"slug": "anuj-github-app",
5+
"node_id": "A_kwDOB7K2ac4ADw2k",
6+
"owner": {
7+
"login": "kaladinstormblessed",
8+
"id": 129152617,
9+
"node_id": "U_kgDOB7K2aQ",
10+
"avatar_url": "https://avatars.githubusercontent.com/u/129152617?v=4",
11+
"gravatar_id": "",
12+
"url": "https://api.github.com/users/kaladinstormblessed",
13+
"html_url": "https://github.com/kaladinstormblessed",
14+
"followers_url": "https://api.github.com/users/kaladinstormblessed/followers",
15+
"following_url": "https://api.github.com/users/kaladinstormblessed/following{/other_user}",
16+
"gists_url": "https://api.github.com/users/kaladinstormblessed/gists{/gist_id}",
17+
"starred_url": "https://api.github.com/users/kaladinstormblessed/starred{/owner}{/repo}",
18+
"subscriptions_url": "https://api.github.com/users/kaladinstormblessed/subscriptions",
19+
"organizations_url": "https://api.github.com/users/kaladinstormblessed/orgs",
20+
"repos_url": "https://api.github.com/users/kaladinstormblessed/repos",
21+
"events_url": "https://api.github.com/users/kaladinstormblessed/events{/privacy}",
22+
"received_events_url": "https://api.github.com/users/kaladinstormblessed/received_events",
23+
"type": "User",
24+
"user_view_type": "public",
25+
"site_admin": false
26+
},
27+
"name": "anuj-github-app",
28+
"description": "",
29+
"external_url": "https://cloud.cloud",
30+
"html_url": "https://github.com/apps/anuj-github-app",
31+
"created_at": "2024-09-03T07:14:38Z",
32+
"updated_at": "2025-01-17T10:52:47Z",
33+
"permissions": {
34+
"administration": "write",
35+
"contents": "write",
36+
"members": "read",
37+
"metadata": "read",
38+
"pull_requests": "read"
39+
},
40+
"events": [],
41+
"installations_count": 6
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[
2+
{
3+
"id": 1037204,
4+
"node_id": "MDMwOkludGVncmF0aW9uSW5zdGFsbGF0aW9uUmVxdWVzdDEwMzcyMDQ=",
5+
"account": {
6+
"login": "approval-test",
7+
"id": 195438329,
8+
"node_id": "O_kgDOC6Ym-Q",
9+
"avatar_url": "https://avatars.githubusercontent.com/u/195438329?v=4",
10+
"gravatar_id": "",
11+
"url": "https://api.github.com/users/approval-test",
12+
"html_url": "https://github.com/approval-test",
13+
"followers_url": "https://api.github.com/users/approval-test/followers",
14+
"following_url": "https://api.github.com/users/approval-test/following{/other_user}",
15+
"gists_url": "https://api.github.com/users/approval-test/gists{/gist_id}",
16+
"starred_url": "https://api.github.com/users/approval-test/starred{/owner}{/repo}",
17+
"subscriptions_url": "https://api.github.com/users/approval-test/subscriptions",
18+
"organizations_url": "https://api.github.com/users/approval-test/orgs",
19+
"repos_url": "https://api.github.com/users/approval-test/repos",
20+
"events_url": "https://api.github.com/users/approval-test/events{/privacy}",
21+
"received_events_url": "https://api.github.com/users/approval-test/received_events",
22+
"type": "Organization",
23+
"user_view_type": "public",
24+
"site_admin": false
25+
},
26+
"requester": {
27+
"login": "kaladinstormblessed2",
28+
"id": 195437694,
29+
"node_id": "U_kgDOC6Ykfg",
30+
"avatar_url": "https://avatars.githubusercontent.com/u/195437694?v=4",
31+
"gravatar_id": "",
32+
"url": "https://api.github.com/users/kaladinstormblessed2",
33+
"html_url": "https://github.com/kaladinstormblessed2",
34+
"followers_url": "https://api.github.com/users/kaladinstormblessed2/followers",
35+
"following_url": "https://api.github.com/users/kaladinstormblessed2/following{/other_user}",
36+
"gists_url": "https://api.github.com/users/kaladinstormblessed2/gists{/gist_id}",
37+
"starred_url": "https://api.github.com/users/kaladinstormblessed2/starred{/owner}{/repo}",
38+
"subscriptions_url": "https://api.github.com/users/kaladinstormblessed2/subscriptions",
39+
"organizations_url": "https://api.github.com/users/kaladinstormblessed2/orgs",
40+
"repos_url": "https://api.github.com/users/kaladinstormblessed2/repos",
41+
"events_url": "https://api.github.com/users/kaladinstormblessed2/events{/privacy}",
42+
"received_events_url": "https://api.github.com/users/kaladinstormblessed2/received_events",
43+
"type": "User",
44+
"user_view_type": "public",
45+
"site_admin": false
46+
},
47+
"created_at": "2025-01-17T15:50:51Z"
48+
}
49+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"id": "7dd11376-7827-4472-9b35-d129d432687e",
3+
"name": "app",
4+
"request": {
5+
"url": "/app",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "application/vnd.github+json"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "1-app.json",
16+
"headers": {
17+
"Date": "Fri, 17 Jan 2025 17:53:40 GMT",
18+
"Content-Type": "application/json; charset=utf-8",
19+
"Cache-Control": "public, max-age=60, s-maxage=60",
20+
"Vary": "Accept,Accept-Encoding, Accept, X-Requested-With",
21+
"ETag": "W/\"2ae03ff428b2f6f2651437f7bbb52bcc5aa4fd43ec20540006591c05a6c4de48\"",
22+
"X-GitHub-Media-Type": "github.v3; format=json",
23+
"x-github-api-version-selected": "2022-11-28",
24+
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
25+
"Access-Control-Allow-Origin": "*",
26+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
27+
"X-Frame-Options": "deny",
28+
"X-Content-Type-Options": "nosniff",
29+
"X-XSS-Protection": "0",
30+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
31+
"Content-Security-Policy": "default-src 'none'",
32+
"Server": "github.com",
33+
"X-GitHub-Request-Id": "C286:10C02C:61556D:734A43:678A9923"
34+
}
35+
},
36+
"uuid": "7dd11376-7827-4472-9b35-d129d432687e",
37+
"persistent": true,
38+
"insertionIndex": 1
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"id": "2e6e47a0-0341-45c9-87f6-eda0865764d7",
3+
"name": "app_installation-requests",
4+
"request": {
5+
"url": "/app/installation-requests",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "application/vnd.github+json"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "2-app_installation-requests.json",
16+
"headers": {
17+
"Date": "Fri, 17 Jan 2025 17:53:40 GMT",
18+
"Content-Type": "application/json; charset=utf-8",
19+
"Cache-Control": "public, max-age=60, s-maxage=60",
20+
"Vary": "Accept,Accept-Encoding, Accept, X-Requested-With",
21+
"ETag": "W/\"1030c589d5482f2436758d79218af5ab17bd8b28c5b92792fe383357cae28d39\"",
22+
"X-GitHub-Media-Type": "github.v3; format=json",
23+
"x-github-api-version-selected": "2022-11-28",
24+
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
25+
"Access-Control-Allow-Origin": "*",
26+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
27+
"X-Frame-Options": "deny",
28+
"X-Content-Type-Options": "nosniff",
29+
"X-XSS-Protection": "0",
30+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
31+
"Content-Security-Policy": "default-src 'none'",
32+
"Server": "github.com",
33+
"X-GitHub-Request-Id": "C287:E5098:509DB7:5CBEB7:678A9924"
34+
}
35+
},
36+
"uuid": "2e6e47a0-0341-45c9-87f6-eda0865764d7",
37+
"persistent": true,
38+
"insertionIndex": 2
39+
}

0 commit comments

Comments
 (0)