use of org.jenkinsci.plugin.gitea.client.api.GiteaHook in project gitea-plugin by jenkinsci.
the class DefaultGiteaConnection method updateHook.
@Override
public void updateHook(GiteaRepository repository, GiteaHook hook) throws IOException, InterruptedException {
GiteaHook diff = new GiteaHook();
diff.setConfig(hook.getConfig());
diff.setActive(hook.isActive());
diff.setEvents(hook.getEvents());
patch(api().literal("/repos").path(UriTemplateBuilder.var("username")).path(UriTemplateBuilder.var("name")).literal("/hooks").path(UriTemplateBuilder.var("id")).build().set("username", repository.getOwner().getUsername()).set("name", repository.getName()).set("id", hook.getId()), diff, Void.class);
}
use of org.jenkinsci.plugin.gitea.client.api.GiteaHook in project gitea-plugin by jenkinsci.
the class MockGiteaConnection method deleteHook.
@Override
public void deleteHook(GiteaRepository repository, long id) throws IOException, InterruptedException {
GiteaHook target = null;
for (Iterator<GiteaHook> iterator = notFoundIfNull(repoHooks.get(keyOf(repository))).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 MockGiteaConnection method withRepo.
public MockGiteaConnection withRepo(GiteaRepository repo) {
GiteaRepository clone = repo.clone();
clone.setId(nextId.incrementAndGet());
clone.setCreatedAt(new Date());
clone.setUpdatedAt(new Date());
this.repositories.put(keyOf(clone), clone);
this.repoHooks.put(keyOf(clone), new ArrayList<GiteaHook>());
this.branches.put(keyOf(clone), new HashMap<String, GiteaBranch>());
this.pulls.put(keyOf(clone), new HashMap<Long, GiteaPullRequest>());
this.issues.put(keyOf(clone), new HashMap<Long, GiteaIssue>());
this.collaborators.put(keyOf(clone), new TreeSet<String>());
this.files.put(keyOf(clone), new TreeMap<String, Map<String, byte[]>>());
return this;
}
use of org.jenkinsci.plugin.gitea.client.api.GiteaHook in project gitea-plugin by jenkinsci.
the class MockGiteaConnection method withOrg.
public MockGiteaConnection withOrg(GiteaOrganization org) {
GiteaOrganization clone = org.clone();
clone.setId(nextId.incrementAndGet());
this.organizations.put(org.getUsername(), clone);
this.orgHooks.put(org.getUsername(), new ArrayList<GiteaHook>());
return this;
}
use of org.jenkinsci.plugin.gitea.client.api.GiteaHook in project gitea-plugin by jenkinsci.
the class MockGiteaConnection method updateHook.
@Override
public void updateHook(GiteaOrganization organization, GiteaHook hook) throws IOException, InterruptedException {
GiteaHook target = null;
for (Iterator<GiteaHook> iterator = notFoundIfNull(orgHooks.get(organization)).iterator(); iterator.hasNext(); ) {
GiteaHook h = iterator.next();
if (h.getId() == hook.getId()) {
target = h;
break;
}
}
notFoundIfNull(target);
target.setUpdatedAt(new Date());
target.setEvents(hook.getEvents());
target.setActive(hook.isActive());
target.setConfig(hook.getConfig());
}
Aggregations