Skip to content

Commit

Permalink
Change requester to GET by default
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseman committed Nov 26, 2019
1 parent 1b55b5f commit 3296cef
Show file tree
Hide file tree
Showing 47 changed files with 252 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class GHAppCreateTokenBuilder {
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
this.root = root;
this.apiUrlTail = apiUrlTail;
this.builder = new Requester(root);
this.builder = root.retrieve().method("POST");
withPermissions(builder, permissions);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kohsuke/github/GHAsset.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public String getBrowserDownloadUrl() {
}

private void edit(String key, Object value) throws IOException {
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
root.retrieve().method("POST").with(key, value).method("PATCH").to(getApiRoute());
}

/**
Expand All @@ -145,7 +145,7 @@ private void edit(String key, Object value) throws IOException {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).method("DELETE").to(getApiRoute());
root.retrieve().method("DELETE").to(getApiRoute());
}

private String getApiRoute() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHBlobBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class GHBlobBuilder {

GHBlobBuilder(GHRepository repo) {
this.repo = repo;
req = new Requester(repo.root);
req = repo.root.retrieve().method("POST");
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/kohsuke/github/GHBranch.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import java.util.Collection;
import java.util.Objects;

import static org.kohsuke.github.Previews.*;

/**
* A branch in a repository.
*
Expand Down Expand Up @@ -122,7 +120,7 @@ public String getSHA1() {
* if disabling protection fails
*/
public void disableProtection() throws IOException {
new Requester(root).method("DELETE").to(protection_url);
root.retrieve().method("DELETE").to(protection_url);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHBranchProtection.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ GHBranchProtection wrap(GHBranch branch) {
}

private Requester requester() {
return new Requester(root).withPreview(ZZZAX);
return root.retrieve().method("POST").withPreview(ZZZAX);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ private StatusChecks getStatusChecks() {
}

private Requester requester() {
return new Requester(branch.getRoot()).withPreview(LUKE_CAGE);
return branch.getRoot().retrieve().method("POST").withPreview(LUKE_CAGE);
}

private static class Restrictions {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/kohsuke/github/GHCommit.java
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,9 @@ public PagedIterable<GHCommitComment> listComments() {
* if comment is not created
*/
public GHCommitComment createComment(String body, String path, Integer line, Integer position) throws IOException {
GHCommitComment r = new Requester(owner.root).with("body", body)
GHCommitComment r = owner.root.retrieve()
.method("POST")
.with("body", body)
.with("path", path)
.with("line", line)
.with("position", position)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHCommitBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private UserInfo(String name, String email, Date date) {

GHCommitBuilder(GHRepository repo) {
this.repo = repo;
req = new Requester(repo.root);
req = repo.root.retrieve().method("POST");
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/kohsuke/github/GHCommitComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,16 @@ public GHCommit getCommit() throws IOException {
* the io exception
*/
public void update(String body) throws IOException {
new Requester(owner.root).with("body", body).method("PATCH").to(getApiTail(), GHCommitComment.class);
owner.root.retrieve().method("POST").with("body", body).method("PATCH").to(getApiTail(), GHCommitComment.class);
this.body = body;
}

@Preview
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return new Requester(owner.root).withPreview(SQUIRREL_GIRL)
return owner.root.retrieve()
.method("POST")
.withPreview(SQUIRREL_GIRL)
.with("content", content.getContent())
.to(getApiTail() + "/reactions", GHReaction.class)
.wrap(owner.root);
Expand All @@ -141,7 +143,7 @@ public PagedIterable<GHReaction> listReactions() {
* the io exception
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE").to(getApiTail());
owner.root.retrieve().method("DELETE").to(getApiTail());
}

private String getApiTail() {
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/kohsuke/github/GHContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessa
throws IOException {
String encodedContent = Base64.encodeBase64String(newContentBytes);

Requester requester = new Requester(root).with("path", path)
Requester requester = root.retrieve()
.method("POST")
.with("path", path)
.with("message", commitMessage)
.with("sha", sha)
.with("content", encodedContent)
Expand Down Expand Up @@ -350,7 +352,9 @@ public GHContentUpdateResponse delete(String message) throws IOException {
* the io exception
*/
public GHContentUpdateResponse delete(String commitMessage, String branch) throws IOException {
Requester requester = new Requester(root).with("path", path)
Requester requester = root.retrieve()
.method("POST")
.with("path", path)
.with("message", commitMessage)
.with("sha", sha)
.method("DELETE");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHContentBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public final class GHContentBuilder {

GHContentBuilder(GHRepository repo) {
this.repo = repo;
this.req = new Requester(repo.root).method("PUT");
this.req = repo.root.retrieve().method("PUT");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class GHCreateRepositoryBuilder {
GHCreateRepositoryBuilder(GitHub root, String apiUrlTail, String name) {
this.root = root;
this.apiUrlTail = apiUrlTail;
this.builder = new Requester(root);
this.builder = root.retrieve().method("POST");
this.builder.with("name", name);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/kohsuke/github/GHDeployKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public String toString() {
* the io exception
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE")
owner.root.retrieve()
.method("DELETE")
.to(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id));
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHDeploymentBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class GHDeploymentBuilder {
*/
public GHDeploymentBuilder(GHRepository repo) {
this.repo = repo;
this.builder = new Requester(repo.root);
this.builder = repo.root.retrieve().method("POST");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public GHDeploymentStatusBuilder(GHRepository repo, int deploymentId, GHDeployme
GHDeploymentStatusBuilder(GHRepository repo, long deploymentId, GHDeploymentState state) {
this.repo = repo;
this.deploymentId = deploymentId;
this.builder = new Requester(repo.root);
this.builder = repo.root.retrieve().method("POST");
this.builder.with("state", state);
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/kohsuke/github/GHGist.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ String getApiTailUrl(String tail) {
* the io exception
*/
public void star() throws IOException {
new Requester(root).method("PUT").to(getApiTailUrl("star"));
root.retrieve().method("PUT").to(getApiTailUrl("star"));
}

/**
Expand All @@ -192,7 +192,7 @@ public void star() throws IOException {
* the io exception
*/
public void unstar() throws IOException {
new Requester(root).method("DELETE").to(getApiTailUrl("star"));
root.retrieve().method("DELETE").to(getApiTailUrl("star"));
}

/**
Expand All @@ -214,7 +214,7 @@ public boolean isStarred() throws IOException {
* the io exception
*/
public GHGist fork() throws IOException {
return new Requester(root).to(getApiTailUrl("forks"), GHGist.class).wrapUp(root);
return root.retrieve().method("POST").to(getApiTailUrl("forks"), GHGist.class).wrapUp(root);
}

/**
Expand All @@ -233,7 +233,7 @@ public PagedIterable<GHGist> listForks() {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).method("DELETE").to("/gists/" + id);
root.retrieve().method("DELETE").to("/gists/" + id);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHGistBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class GHGistBuilder {
*/
public GHGistBuilder(GitHub root) {
this.root = root;
req = new Requester(root);
req = root.retrieve().method("POST");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHGistUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class GHGistUpdater {

GHGistUpdater(GHGist base) {
this.base = base;
this.builder = new Requester(base.root);
this.builder = base.root.retrieve().method("POST");

files = new LinkedHashMap<>();
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kohsuke/github/GHHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Map<String, String> getConfig() {
* @see <a href="https://developer.github.com/v3/repos/hooks/#ping-a-hook">Ping hook</a>
*/
public void ping() throws IOException {
new Requester(getRoot()).method("POST").to(getApiRoute() + "/pings");
getRoot().retrieve().method("POST").to(getApiRoute() + "/pings");
}

/**
Expand All @@ -84,7 +84,7 @@ public void ping() throws IOException {
* the io exception
*/
public void delete() throws IOException {
new Requester(getRoot()).method("DELETE").to(getApiRoute());
getRoot().retrieve().method("DELETE").to(getApiRoute());
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/kohsuke/github/GHHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public GHHook createHook(String name, Map<String, String> config, Collection<GHE
ea.add(e.symbol());
}

GHHook hook = new Requester(root).with("name", name)
GHHook hook = root.retrieve()
.method("POST")
.with("name", name)
.with("active", active)
.with("config", config)
.with("events", ea)
Expand Down
18 changes: 11 additions & 7 deletions src/main/java/org/kohsuke/github/GHIssue.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public URL getApiURL() {
* the io exception
*/
public void lock() throws IOException {
new Requester(root).method("PUT").to(getApiRoute() + "/lock");
root.retrieve().method("PUT").to(getApiRoute() + "/lock");
}

/**
Expand All @@ -216,7 +216,7 @@ public void lock() throws IOException {
* the io exception
*/
public void unlock() throws IOException {
new Requester(root).method("PUT").to(getApiRoute() + "/lock");
root.retrieve().method("PUT").to(getApiRoute() + "/lock");
}

/**
Expand All @@ -230,17 +230,19 @@ public void unlock() throws IOException {
*/
@WithBridgeMethods(void.class)
public GHIssueComment comment(String message) throws IOException {
GHIssueComment r = new Requester(root).with("body", message)
GHIssueComment r = root.retrieve()
.method("POST")
.with("body", message)
.to(getIssuesApiRoute() + "/comments", GHIssueComment.class);
return r.wrapUp(this);
}

private void edit(String key, Object value) throws IOException {
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
root.retrieve().method("POST").with(key, value).method("PATCH").to(getApiRoute());
}

private void editIssue(String key, Object value) throws IOException {
new Requester(root).with(key, value).method("PATCH").to(getIssuesApiRoute());
root.retrieve().method("POST").with(key, value).method("PATCH").to(getIssuesApiRoute());
}

/**
Expand Down Expand Up @@ -451,7 +453,9 @@ public PagedIterable<GHIssueComment> listComments() throws IOException {
@Preview
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return new Requester(owner.root).withPreview(SQUIRREL_GIRL)
return owner.root.retrieve()
.method("POST")
.withPreview(SQUIRREL_GIRL)
.with("content", content.getContent())
.to(getApiRoute() + "/reactions", GHReaction.class)
.wrap(root);
Expand Down Expand Up @@ -513,7 +517,7 @@ public void setAssignees(GHUser... assignees) throws IOException {
* the io exception
*/
public void setAssignees(Collection<GHUser> assignees) throws IOException {
new Requester(root).with(ASSIGNEES, getLogins(assignees)).method("PATCH").to(getIssuesApiRoute());
root.retrieve().method("POST").with(ASSIGNEES, getLogins(assignees)).method("PATCH").to(getIssuesApiRoute());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHIssueBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class GHIssueBuilder {

GHIssueBuilder(GHRepository repo, String title) {
this.repo = repo;
this.builder = new Requester(repo.root);
this.builder = repo.root.retrieve().method("POST");
builder.with("title", title);
}

Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/kohsuke/github/GHIssueComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public GHCommentAuthorAssociation getAuthorAssociation() {
* the io exception
*/
public void update(String body) throws IOException {
new Requester(owner.root).with("body", body).method("PATCH").to(getApiRoute(), GHIssueComment.class);
owner.root.retrieve().method("POST").with("body", body).method("PATCH").to(getApiRoute(), GHIssueComment.class);
this.body = body;
}

Expand All @@ -119,13 +119,15 @@ public void update(String body) throws IOException {
* the io exception
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE").to(getApiRoute());
owner.root.retrieve().method("DELETE").to(getApiRoute());
}

@Preview
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return new Requester(owner.root).withPreview(SQUIRREL_GIRL)
return owner.root.retrieve()
.method("POST")
.withPreview(SQUIRREL_GIRL)
.with("content", content.getContent())
.to(getApiRoute() + "/reactions", GHReaction.class)
.wrap(owner.root);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHMilestone.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void delete() throws IOException {
}

private void edit(String key, Object value) throws IOException {
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
root.retrieve().method("POST").with(key, value).method("PATCH").to(getApiRoute());
}

/**
Expand Down
Loading

0 comments on commit 3296cef

Please sign in to comment.