Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete TagApiRestClient #196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.common.collect.Iterables;
import com.google.gerrit.extensions.api.projects.TagApi;
import com.google.gerrit.extensions.api.projects.TagInfo;
import com.google.gerrit.extensions.api.projects.TagInput;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gson.JsonElement;
import com.urswolfer.gerrit.client.rest.http.GerritRestClient;
Expand All @@ -42,12 +43,24 @@ public TagApiRestClient(GerritRestClient gerritRestClient,
this.name = name;
}

@Override
public TagApi create(TagInput input) throws RestApiException {
String json = gerritRestClient.getGson().toJson(input);
gerritRestClient.putRequest(tagUrl(), json);
return this;
}

@Override
public TagInfo get() throws RestApiException {
JsonElement jsonElement = gerritRestClient.getRequest(tagUrl());
return Iterables.getOnlyElement(tagInfoParser.parseTagInfos(jsonElement));
}

@Override
public void delete() throws RestApiException {
gerritRestClient.deleteRequest(tagUrl());
}

protected String tagUrl() {
return projectApiRestClient.projectsUrl() + "/tags/" + name;
}
Expand Down