use of org.jenkinsci.plugin.gitea.client.api.GiteaHook in project gitea-plugin by jenkinsci.
the class MockGiteaConnection method createHook.
@Override
public GiteaHook createHook(GiteaOrganization organization, GiteaHook hook) throws IOException, InterruptedException {
List<GiteaHook> list = notFoundIfNull(orgHooks.get(organization));
hook = hook.clone();
hook.setId(nextId.incrementAndGet());
hook.setCreatedAt(new Date());
hook.setUpdatedAt(hook.getCreatedAt());
list.add(hook);
return hook.clone();
}
use of org.jenkinsci.plugin.gitea.client.api.GiteaHook in project gitea-plugin by jenkinsci.
the class MockGiteaConnection method deleteHook.
@Override
public void deleteHook(GiteaOrganization organization, long id) throws IOException, InterruptedException {
GiteaHook target = null;
for (Iterator<GiteaHook> iterator = notFoundIfNull(orgHooks.get(organization)).iterator(); iterator.hasNext(); ) {
GiteaHook h = iterator.next();
if (h.getId() == id) {
iterator.remove();
target = h;
break;
}
}
notFoundIfNull(target);
}
use of org.jenkinsci.plugin.gitea.client.api.GiteaHook in project gitea-plugin by jenkinsci.
the class DefaultGiteaConnection method updateHook.
@Override
public void updateHook(GiteaOrganization organization, GiteaHook hook) throws IOException, InterruptedException {
GiteaHook diff = new GiteaHook();
diff.setConfig(hook.getConfig());
diff.setActive(hook.isActive());
diff.setEvents(hook.getEvents());
patch(api().literal("/orgs").path(UriTemplateBuilder.var("name")).literal("/hooks").path(UriTemplateBuilder.var("id")).build().set("name", organization.getUsername()).set("id", hook.getId()), diff, Void.class);
}
Aggregations