Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c4de682

Browse filesBrowse files
committed
(feat) Add method to check if Organization has projects enabled
[hub4j#1080]
1 parent f531096 commit c4de682
Copy full SHA for c4de682

File tree

Expand file treeCollapse file tree

6 files changed

+220
-0
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+220
-0
lines changed

‎src/main/java/org/kohsuke/github/GHOrganization.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHOrganization.java
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
* @author Kohsuke Kawaguchi
1919
*/
2020
public class GHOrganization extends GHPerson {
21+
22+
private boolean has_organization_projects;
23+
2124
GHOrganization wrapUp(GitHub root) {
2225
return (GHOrganization) super.wrapUp(root);
2326
}
@@ -367,6 +370,15 @@ public void conceal(GHUser u) throws IOException {
367370
root.createRequest().method("DELETE").withUrlPath("/orgs/" + login + "/public_members/" + u.getLogin()).send();
368371
}
369372

373+
/**
374+
* Are projects enabled for organization boolean.
375+
*
376+
* @return the boolean
377+
*/
378+
public boolean areOrganizationProjectsEnabled() {
379+
return has_organization_projects;
380+
}
381+
370382
/**
371383
* Returns the projects for this organization.
372384
*

‎src/test/java/org/kohsuke/github/GHOrganizationTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHOrganizationTest.java
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ public void cleanUpTeam() throws IOException {
2929
if (team != null) {
3030
team.delete();
3131
}
32+
33+
getNonRecordingGitHub().getOrganization(GITHUB_API_TEST_ORG).root.createRequest()
34+
.withUrlPath("/orgs/" + GITHUB_API_TEST_ORG)
35+
.method("PATCH")
36+
.with("has_organization_projects", true)
37+
.send();
3238
}
3339

3440
@Test
@@ -231,4 +237,16 @@ public void testCreateAllArgsTeam() throws IOException {
231237
assertThat(team.getDescription(), equalTo("Team description"));
232238
assertThat(team.getPrivacy(), equalTo(GHTeam.Privacy.CLOSED));
233239
}
240+
241+
@Test
242+
public void testAreOrganizationProjectsEnabled() throws IOException {
243+
// Arrange
244+
GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG);
245+
246+
// Act
247+
boolean result = org.areOrganizationProjectsEnabled();
248+
249+
// Assert that projects are enabled
250+
assertThat(result, is(true));
251+
}
234252
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"login": "hub4j-test-org",
3+
"id": 7544739,
4+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
5+
"url": "https://api.github.com/orgs/hub4j-test-org",
6+
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
7+
"events_url": "https://api.github.com/orgs/hub4j-test-org/events",
8+
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
9+
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
10+
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
11+
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
12+
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
13+
"description": "Hub4j Test Org Description (this could be null or blank too)",
14+
"name": "Hub4j Test Org Name (this could be null or blank too)",
15+
"company": null,
16+
"blog": "https://hub4j.url.io/could/be/null",
17+
"location": "Hub4j Test Org Location (this could be null or blank too)",
18+
"email": "hub4jtestorgemail@could.be.null.com",
19+
"twitter_username": null,
20+
"is_verified": false,
21+
"has_organization_projects": true,
22+
"has_repository_projects": true,
23+
"public_repos": 17,
24+
"public_gists": 0,
25+
"followers": 0,
26+
"following": 0,
27+
"html_url": "https://github.com/hub4j-test-org",
28+
"created_at": "2014-05-10T19:39:11Z",
29+
"updated_at": "2020-06-04T05:56:10Z",
30+
"type": "Organization",
31+
"total_private_repos": 2,
32+
"owned_private_repos": 2,
33+
"private_gists": 0,
34+
"disk_usage": 31,
35+
"collaborators": 0,
36+
"billing_email": "kk@kohsuke.org",
37+
"default_repository_permission": "none",
38+
"members_can_create_repositories": false,
39+
"two_factor_requirement_enabled": false,
40+
"members_can_create_pages": true,
41+
"members_can_create_public_pages": true,
42+
"members_can_create_private_pages": true,
43+
"plan": {
44+
"name": "free",
45+
"space": 976562499,
46+
"private_repos": 10000,
47+
"filled_seats": 23,
48+
"seats": 3
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"login": "akashRindhe",
3+
"id": 14114123,
4+
"node_id": "MDQ6VXNlcjE0MTE0MTIz",
5+
"avatar_url": "https://avatars.githubusercontent.com/u/14114123?v=4",
6+
"gravatar_id": "",
7+
"url": "https://api.github.com/users/akashRindhe",
8+
"html_url": "https://github.com/akashRindhe",
9+
"followers_url": "https://api.github.com/users/akashRindhe/followers",
10+
"following_url": "https://api.github.com/users/akashRindhe/following{/other_user}",
11+
"gists_url": "https://api.github.com/users/akashRindhe/gists{/gist_id}",
12+
"starred_url": "https://api.github.com/users/akashRindhe/starred{/owner}{/repo}",
13+
"subscriptions_url": "https://api.github.com/users/akashRindhe/subscriptions",
14+
"organizations_url": "https://api.github.com/users/akashRindhe/orgs",
15+
"repos_url": "https://api.github.com/users/akashRindhe/repos",
16+
"events_url": "https://api.github.com/users/akashRindhe/events{/privacy}",
17+
"received_events_url": "https://api.github.com/users/akashRindhe/received_events",
18+
"type": "User",
19+
"site_admin": false,
20+
"name": "Akash Rindhe",
21+
"company": null,
22+
"blog": "",
23+
"location": "Singapore",
24+
"email": null,
25+
"hireable": null,
26+
"bio": null,
27+
"twitter_username": null,
28+
"public_repos": 9,
29+
"public_gists": 0,
30+
"followers": 0,
31+
"following": 6,
32+
"created_at": "2015-09-03T18:07:43Z",
33+
"updated_at": "2021-05-12T08:30:12Z",
34+
"private_gists": 0,
35+
"total_private_repos": 4,
36+
"owned_private_repos": 4,
37+
"disk_usage": 24551,
38+
"collaborators": 1,
39+
"two_factor_authentication": true,
40+
"plan": {
41+
"name": "free",
42+
"space": 976562499,
43+
"collaborators": 0,
44+
"private_repos": 10000
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"id": "d0322427-888c-40d9-a47d-b7c0f1d2fc71",
3+
"name": "orgs_hub4j-test-org",
4+
"request": {
5+
"url": "/orgs/hub4j-test-org",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "orgs_hub4j-test-org-2.json",
16+
"headers": {
17+
"Server": "GitHub.com",
18+
"Date": "Thu, 13 May 2021 16:11:19 GMT",
19+
"Content-Type": "application/json; charset=utf-8",
20+
"Cache-Control": "private, max-age=60, s-maxage=60",
21+
"Vary": [
22+
"Accept, Authorization, Cookie, X-GitHub-OTP",
23+
"Accept-Encoding, Accept, X-Requested-With"
24+
],
25+
"ETag": "W/\"43be1c5d1d3fa4718ddcd58ebd6be4a41f81ddb5c2102d6ddd628548059db30d\"",
26+
"Last-Modified": "Thu, 04 Jun 2020 05:56:10 GMT",
27+
"X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages",
28+
"X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
29+
"X-GitHub-Media-Type": "unknown, github.v3",
30+
"X-RateLimit-Limit": "5000",
31+
"X-RateLimit-Remaining": "4958",
32+
"X-RateLimit-Reset": "1620924638",
33+
"X-RateLimit-Used": "42",
34+
"X-RateLimit-Resource": "core",
35+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
36+
"X-Frame-Options": "deny",
37+
"X-Content-Type-Options": "nosniff",
38+
"X-XSS-Protection": "0",
39+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
40+
"Content-Security-Policy": "default-src 'none'",
41+
"X-GitHub-Request-Id": "8358:203B:A245B6:B13792:609D4FA7"
42+
}
43+
},
44+
"uuid": "d0322427-888c-40d9-a47d-b7c0f1d2fc71",
45+
"persistent": true,
46+
"insertionIndex": 2
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"id": "28895477-e3e7-4621-9a69-834956cf26d7",
3+
"name": "user",
4+
"request": {
5+
"url": "/user",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "user-1.json",
16+
"headers": {
17+
"Server": "GitHub.com",
18+
"Date": "Thu, 13 May 2021 16:11:17 GMT",
19+
"Content-Type": "application/json; charset=utf-8",
20+
"Cache-Control": "private, max-age=60, s-maxage=60",
21+
"Vary": [
22+
"Accept, Authorization, Cookie, X-GitHub-OTP",
23+
"Accept-Encoding, Accept, X-Requested-With"
24+
],
25+
"ETag": "W/\"848579fd41f059ee3a1a46f41bea53042fd2303af9d8670074420dc05bcfbd73\"",
26+
"Last-Modified": "Wed, 12 May 2021 08:30:12 GMT",
27+
"X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages",
28+
"X-Accepted-OAuth-Scopes": "",
29+
"X-GitHub-Media-Type": "unknown, github.v3",
30+
"X-RateLimit-Limit": "5000",
31+
"X-RateLimit-Remaining": "4963",
32+
"X-RateLimit-Reset": "1620924638",
33+
"X-RateLimit-Used": "37",
34+
"X-RateLimit-Resource": "core",
35+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
36+
"X-Frame-Options": "deny",
37+
"X-Content-Type-Options": "nosniff",
38+
"X-XSS-Protection": "0",
39+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
40+
"Content-Security-Policy": "default-src 'none'",
41+
"X-GitHub-Request-Id": "8358:203B:A24554:B13727:609D4FA5"
42+
}
43+
},
44+
"uuid": "28895477-e3e7-4621-9a69-834956cf26d7",
45+
"persistent": true,
46+
"insertionIndex": 1
47+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.