/** * Retrieves the currently configured hooks. */ public List<GHHook> getHooks() throws IOException { List<GHHook> list = new ArrayList<GHHook>(Arrays.asList( root.retrieve().to(getApiTailUrl("hooks"), GHHook[].class))); for (GHHook h : list) h.wrap(this); return list; }
public GHHook getHook(int id) throws IOException { return root.retrieve().to(getApiTailUrl("hooks/" + id), GHHook.class).wrap(this); }
/** * * See https://api.github.com/hooks for possible names and their configuration scheme. * TODO: produce type-safe binding * * @param name * Type of the hook to be created. See https://api.github.com/hooks for possible names. * @param config * The configuration hash. * @param events * Can be null. Types of events to hook into. */ public GHHook createHook(String name, Map<String,String> config, Collection<GHEvent> events, boolean active) throws IOException { List<String> ea = null; if (events!=null) { ea = new ArrayList<String>(); for (GHEvent e : events) ea.add(e.name().toLowerCase(Locale.ENGLISH)); } return new Requester(root) .with("name", name) .with("active", active) ._with("config", config) ._with("events",ea) .to(String.format("/repos/%s/%s/hooks",owner.login,this.name),GHHook.class).wrap(this); }