Skip to content

Commit 7fb8c79

Browse files
authored
Merge branch 'main' into feature/hub4j#1497
2 parents 6597aa6 + b4ac83a commit 7fb8c79

File tree

180 files changed

+56892
-1205
lines changed

Some content is hidden

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

180 files changed

+56892
-1205
lines changed

.github/workflows/maven-build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
uses: actions/setup-java@v3
3232
with:
3333
java-version: ${{ matrix.java }}
34-
distribution: 'zulu'
34+
distribution: 'temurin'
3535
cache: 'maven'
3636
- name: Maven Install (skipTests)
3737
env:
@@ -50,7 +50,7 @@ jobs:
5050
uses: actions/setup-java@v3
5151
with:
5252
java-version: ${{ matrix.java }}
53-
distribution: 'adopt'
53+
distribution: 'temurin'
5454
cache: 'maven'
5555
- name: Maven Site
5656
env:
@@ -70,7 +70,7 @@ jobs:
7070
uses: actions/setup-java@v3
7171
with:
7272
java-version: ${{ matrix.java }}
73-
distribution: 'zulu'
73+
distribution: 'temurin'
7474
cache: 'maven'
7575
# JDK 8
7676
- name: Maven Install with Code Coverage
@@ -91,7 +91,7 @@ jobs:
9191
uses: actions/setup-java@v3
9292
with:
9393
java-version: ${{ matrix.java }}
94-
distribution: 'zulu'
94+
distribution: 'temurin'
9595
cache: 'maven'
9696
# JDK 11+
9797
- name: Maven Install without Code Coverage

pom.xml

Lines changed: 9 additions & 3 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>1.314-SNAPSHOT</version>
5+
<version>1.315-SNAPSHOT</version>
66
<name>GitHub API for Java</name>
77
<url>https://github-api.kohsuke.org/</url>
88
<description>GitHub API for Java</description>
@@ -396,7 +396,7 @@
396396
<plugin>
397397
<groupId>com.github.siom79.japicmp</groupId>
398398
<artifactId>japicmp-maven-plugin</artifactId>
399-
<version>0.16.0</version>
399+
<version>0.17.1</version>
400400
<configuration>
401401
<parameter>
402402
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
@@ -453,6 +453,12 @@
453453
<version>${hamcrest.version}</version>
454454
<scope>test</scope>
455455
</dependency>
456+
<dependency>
457+
<groupId>com.github.npathai</groupId>
458+
<artifactId>hamcrest-optional</artifactId>
459+
<version>2.0.0</version>
460+
<scope>test</scope>
461+
</dependency>
456462
<dependency>
457463
<groupId>junit</groupId>
458464
<artifactId>junit</artifactId>
@@ -698,7 +704,7 @@
698704
<plugin>
699705
<groupId>org.apache.maven.plugins</groupId>
700706
<artifactId>maven-enforcer-plugin</artifactId>
701-
<version>3.1.0</version>
707+
<version>3.2.1</version>
702708
<executions>
703709
<execution>
704710
<id>enforce-jacoco-exist</id>

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,4 +366,25 @@ public GHAppCreateTokenBuilder createToken(Map<String, GHPermissionType> permiss
366366
public GHAppCreateTokenBuilder createToken() {
367367
return new GHAppCreateTokenBuilder(root(), String.format("/app/installations/%d/access_tokens", getId()));
368368
}
369+
370+
/**
371+
* Shows whether the user or organization account actively subscribes to a plan listed by the authenticated GitHub
372+
* App. When someone submits a plan change that won't be processed until the end of their billing cycle, you will
373+
* also see the upcoming pending change.
374+
*
375+
* <p>
376+
* GitHub Apps must use a JWT to access this endpoint.
377+
* <p>
378+
* OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.
379+
*
380+
* @return a GHMarketplaceAccountPlan instance
381+
* @throws IOException
382+
* it may throw an {@link IOException}
383+
* @see <a href=
384+
* "https://docs.github.com/en/rest/apps/marketplace?apiVersion=2022-11-28#get-a-subscription-plan-for-an-account">Get
385+
* a subscription plan for an account</a>
386+
*/
387+
public GHMarketplaceAccountPlan getMarketplaceAccount() throws IOException {
388+
return new GHMarketplacePlanForAccountBuilder(root(), account.getId()).createRequest();
389+
}
369390
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package org.kohsuke.github;
2+
3+
/**
4+
* Represents an error in a {@code CODEOWNERS} file. See <a href=
5+
* "https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners">the
6+
* relevant documentation</a>.
7+
*
8+
* @author Michael Grant
9+
*/
10+
public class GHCodeownersError {
11+
private int line, column;
12+
13+
private String kind, source, suggestion, message, path;
14+
15+
/**
16+
* Gets line.
17+
*
18+
* @return the line
19+
*/
20+
public int getLine() {
21+
return line;
22+
}
23+
24+
/**
25+
* Gets column.
26+
*
27+
* @return the column
28+
*/
29+
public int getColumn() {
30+
return column;
31+
}
32+
33+
/**
34+
* Gets kind.
35+
*
36+
* @return the kind
37+
*/
38+
public String getKind() {
39+
return kind;
40+
}
41+
42+
/**
43+
* Gets source.
44+
*
45+
* @return the source
46+
*/
47+
public String getSource() {
48+
return source;
49+
}
50+
51+
/**
52+
* Gets suggestion.
53+
*
54+
* @return the suggestion
55+
*/
56+
public String getSuggestion() {
57+
return suggestion;
58+
}
59+
60+
/**
61+
* Gets message.
62+
*
63+
* @return the message
64+
*/
65+
public String getMessage() {
66+
return message;
67+
}
68+
69+
/**
70+
* Gets path.
71+
*
72+
* @return the path
73+
*/
74+
public String getPath() {
75+
return path;
76+
}
77+
}

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

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.apache.commons.lang3.builder.ToStringBuilder;
44

55
import java.io.IOException;
6+
import java.util.Date;
67

78
// TODO: Auto-generated Javadoc
89
/**
@@ -20,6 +21,18 @@ public class GHDeployKey {
2021
protected long id;
2122
private GHRepository owner;
2223

24+
/** Creation date of the deploy key */
25+
private String created_at;
26+
27+
/** Last used date of the deploy key */
28+
private String last_used;
29+
30+
/** Name of user that added the deploy key */
31+
private String added_by;
32+
33+
/** Whether the deploykey has readonly permission or full access */
34+
private boolean read_only;
35+
2336
/**
2437
* Gets id.
2538
*
@@ -65,6 +78,42 @@ public boolean isVerified() {
6578
return verified;
6679
}
6780

81+
/**
82+
* Gets created_at.
83+
*
84+
* @return the created_at
85+
*/
86+
public Date getCreatedAt() {
87+
return GitHubClient.parseDate(created_at);
88+
}
89+
90+
/**
91+
* Gets last_used.
92+
*
93+
* @return the last_used
94+
*/
95+
public Date getLastUsedAt() {
96+
return GitHubClient.parseDate(last_used);
97+
}
98+
99+
/**
100+
* Gets added_by
101+
*
102+
* @return the added_by
103+
*/
104+
public String getAdded_by() {
105+
return added_by;
106+
}
107+
108+
/**
109+
* Is read_only
110+
*
111+
* @return true if the key can only read. False if the key has write permission as well.
112+
*/
113+
public boolean isRead_only() {
114+
return read_only;
115+
}
116+
68117
/**
69118
* Wrap gh deploy key.
70119
*
@@ -95,7 +144,14 @@ GHDeployKey lateBind(GHRepository repo) {
95144
* @return the string
96145
*/
97146
public String toString() {
98-
return new ToStringBuilder(this).append("title", title).append("id", id).append("key", key).toString();
147+
return new ToStringBuilder(this).append("title", title)
148+
.append("id", id)
149+
.append("key", key)
150+
.append("created_at", created_at)
151+
.append("last_used", last_used)
152+
.append("added_by", added_by)
153+
.append("read_only", read_only)
154+
.toString();
99155
}
100156

101157
/**

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
44
import org.apache.commons.lang3.builder.ToStringBuilder;
55

6+
import java.io.IOException;
7+
68
// TODO: Auto-generated Javadoc
79
/**
810
* SSH public key.
@@ -74,4 +76,14 @@ public boolean isVerified() {
7476
public String toString() {
7577
return new ToStringBuilder(this).append("title", title).append("id", id).append("key", key).toString();
7678
}
79+
80+
/**
81+
* Delete the GHKey
82+
*
83+
* @throws IOException
84+
* the io exception
85+
*/
86+
public void delete() throws IOException {
87+
root().createRequest().method("DELETE").withUrlPath(String.format("/user/keys/%d", id)).send();
88+
}
7789
}

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.kohsuke.github;
22

3+
import java.io.IOException;
34
import java.net.URL;
45

56
// TODO: Auto-generated Javadoc
@@ -72,4 +73,25 @@ public GHMarketplaceAccountType getType() {
7273
return type;
7374
}
7475

76+
/**
77+
* Shows whether the user or organization account actively subscribes to a plan listed by the authenticated GitHub
78+
* App. When someone submits a plan change that won't be processed until the end of their billing cycle, you will
79+
* also see the upcoming pending change.
80+
*
81+
* <p>
82+
* GitHub Apps must use a JWT to access this endpoint.
83+
* <p>
84+
* OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.
85+
*
86+
* @return a GHMarketplaceListAccountBuilder instance
87+
* @throws IOException
88+
* in case of {@link IOException}
89+
* @see <a href=
90+
* "https://docs.github.com/en/rest/apps/marketplace?apiVersion=2022-11-28#get-a-subscription-plan-for-an-account">Get
91+
* a subscription plan for an account</a>
92+
*/
93+
public GHMarketplaceAccountPlan getPlan() throws IOException {
94+
return new GHMarketplacePlanForAccountBuilder(root(), this.id).createRequest();
95+
}
96+
7597
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.kohsuke.github;
2+
3+
import java.io.IOException;
4+
5+
// TODO: Auto-generated Javadoc
6+
/**
7+
* Returns the plan associated with current account.
8+
*
9+
* @author Benoit Lacelle
10+
* @see GHMarketplacePlan#listAccounts()
11+
* @see GitHub#listMarketplacePlans()
12+
*/
13+
public class GHMarketplacePlanForAccountBuilder extends GitHubInteractiveObject {
14+
private final Requester builder;
15+
private final long accountId;
16+
17+
/**
18+
* Instantiates a new GH marketplace list account builder.
19+
*
20+
* @param root
21+
* the root
22+
* @param accountId
23+
* the account id
24+
*/
25+
GHMarketplacePlanForAccountBuilder(GitHub root, long accountId) {
26+
super(root);
27+
this.builder = root.createRequest();
28+
this.accountId = accountId;
29+
}
30+
31+
/**
32+
* Fetch the plan associated with the account specified on construction.
33+
* <p>
34+
* GitHub Apps must use a JWT to access this endpoint.
35+
*
36+
* @return a GHMarketplaceAccountPlan
37+
* @throws IOException
38+
* on error
39+
*/
40+
public GHMarketplaceAccountPlan createRequest() throws IOException {
41+
return builder.withUrlPath(String.format("/marketplace_listing/accounts/%d", this.accountId))
42+
.fetch(GHMarketplaceAccountPlan.class);
43+
}
44+
45+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
public enum GHMarketplacePriceModel {
1313

1414
/** The free. */
15-
FREE("free"),
15+
FREE("FREE"),
1616
/** The per unit. */
17-
PER_UNIT("per-unit"),
17+
PER_UNIT("PER_UNIT"),
1818
/** The flat rate. */
19-
FLAT_RATE("flat-rate");
19+
FLAT_RATE("FLAT_RATE");
2020

2121
@JsonValue
2222
private final String internalName;

0 commit comments

Comments
 (0)