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 541afca

Browse filesBrowse files
committed
Add delete webhook via id functionality.
1 parent bcb71a3 commit 541afca
Copy full SHA for 541afca

File tree

Expand file treeCollapse file tree

4 files changed

+36
-2
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+36
-2
lines changed

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHHooks.java
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ public GHHook createHook(String name, Map<String, String> config, Collection<GHE
8787
return wrap(hook);
8888
}
8989

90+
/**
91+
* Deletes hook.
92+
*
93+
* @param id
94+
* the id
95+
* @throws IOException
96+
* the io exception
97+
*/
98+
public void deleteHook(int id) throws IOException {
99+
root().createRequest().method("DELETE").withUrlPath(collection() + "/" + id).send();
100+
}
101+
90102
abstract String collection();
91103

92104
abstract Class<? extends GHHook[]> collectionClass();

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHOrganization.java
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,16 @@ public GHHook getHook(int id) throws IOException {
640640
return GHHooks.orgContext(this).getHook(id);
641641
}
642642

643+
/**
644+
* Deletes hook.
645+
*
646+
* @param id
647+
* @throws IOException
648+
*/
649+
public void deleteHook(int id) throws IOException {
650+
GHHooks.orgContext(this).deleteHook(id);
651+
}
652+
643653
/**
644654
* See https://api.github.com/hooks for possible names and their configuration scheme. TODO: produce type-safe
645655
* binding

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepository.java
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,18 @@ public GHHook getHook(int id) throws IOException {
16481648
return GHHooks.repoContext(this, owner).getHook(id);
16491649
}
16501650

1651+
/**
1652+
* Deletes hook.
1653+
*
1654+
* @param id
1655+
* the id
1656+
* @throws IOException
1657+
* the io exception
1658+
*/
1659+
public void deleteHook(int id) throws IOException {
1660+
GHHooks.repoContext(this, owner).deleteHook(id);
1661+
}
1662+
16511663
/**
16521664
* Sets {@link #getCompare(String, String)} to return a {@link GHCompare} that uses a paginated commit list instead
16531665
* of limiting to 250 results.

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

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/AppTest.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ public void tryHook() throws Exception {
637637
assertThat(hook2.getConfig().size(), equalTo(3));
638638
assertThat(hook2.isActive(), equalTo(true));
639639
hook2.ping();
640-
hook2.delete();
640+
r.deleteHook((int) hook.getId());
641641

642642
hook = o.createWebHook(new URL("http://www.google.com/"));
643643
assertThat(hook.getName(), equalTo("web"));
@@ -653,7 +653,7 @@ public void tryHook() throws Exception {
653653
assertThat(hook2.getConfig().size(), equalTo(3));
654654
assertThat(hook2.isActive(), equalTo(true));
655655
hook2.ping();
656-
hook2.delete();
656+
o.deleteHook((int) hook.getId());
657657

658658
// System.out.println(hook);
659659
} finally {

0 commit comments

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