Skip to content
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