diff --git a/src/main/java/com/google/gerrit/extensions/api/changes/RevisionApi.java b/src/main/java/com/google/gerrit/extensions/api/changes/RevisionApi.java index b23c7f90..ffd4b3d3 100644 --- a/src/main/java/com/google/gerrit/extensions/api/changes/RevisionApi.java +++ b/src/main/java/com/google/gerrit/extensions/api/changes/RevisionApi.java @@ -32,6 +32,8 @@ public interface RevisionApi { void delete() throws RestApiException; void review(ReviewInput in) throws RestApiException; + // for verify-status-reporter plugin + VerifyStatusApi verifyStatus() throws RestApiException; void submit() throws RestApiException; void submit(SubmitInput in) throws RestApiException; @@ -86,6 +88,12 @@ public void review(ReviewInput in) throws RestApiException { throw new NotImplementedException(); } + // for verify-status-reporter plugin + @Override + public VerifyStatusApi verifyStatus() throws RestApiException { + throw new NotImplementedException(); + } + @Override public void submit() throws RestApiException { throw new NotImplementedException(); diff --git a/src/main/java/com/google/gerrit/extensions/api/changes/VerifyInput.java b/src/main/java/com/google/gerrit/extensions/api/changes/VerifyInput.java new file mode 100644 index 00000000..97dd4421 --- /dev/null +++ b/src/main/java/com/google/gerrit/extensions/api/changes/VerifyInput.java @@ -0,0 +1,25 @@ +// Copyright (C) 2015 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.extensions.api.changes; + +import com.google.gerrit.extensions.common.VerificationInfo; +import com.google.gerrit.extensions.restapi.DefaultInput; + +import java.util.Map; + +public class VerifyInput { + @DefaultInput + public Map verifications; +} \ No newline at end of file diff --git a/src/main/java/com/google/gerrit/extensions/api/changes/VerifyStatusApi.java b/src/main/java/com/google/gerrit/extensions/api/changes/VerifyStatusApi.java new file mode 100644 index 00000000..f45b1f2f --- /dev/null +++ b/src/main/java/com/google/gerrit/extensions/api/changes/VerifyStatusApi.java @@ -0,0 +1,39 @@ +// Copyright (C) 2016 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.extensions.api.changes; + +import com.google.gerrit.extensions.restapi.NotImplementedException; +import com.google.gerrit.extensions.restapi.RestApiException; + +/** + * Support for the REST endpoints provided by the Gerrit Verify Status plugin + * @author zaro0508 + * + */ +public interface VerifyStatusApi { + void verifications(VerifyInput verifyInput) throws RestApiException; + + + /** + * A default implementation which allows source compatibility + * when adding new methods to the interface. + **/ + public class NotImplemented implements VerifyStatusApi { + @Override + public void verifications(VerifyInput verifyInput) throws RestApiException { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/google/gerrit/extensions/common/VerificationInfo.java b/src/main/java/com/google/gerrit/extensions/common/VerificationInfo.java new file mode 100644 index 00000000..c4b94464 --- /dev/null +++ b/src/main/java/com/google/gerrit/extensions/common/VerificationInfo.java @@ -0,0 +1,30 @@ +// Copyright (C) 2015 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.extensions.common; + +import java.sql.Timestamp; + +public class VerificationInfo { + public String name; + public String url; + public Short value; + public boolean abstain; + public boolean rerun; + public String reporter; + public String comment; + public Timestamp granted; + public String category; + public String duration; +} \ No newline at end of file diff --git a/src/main/java/com/urswolfer/gerrit/client/rest/http/changes/RevisionApiRestClient.java b/src/main/java/com/urswolfer/gerrit/client/rest/http/changes/RevisionApiRestClient.java index e2fcbf4e..c8ae6375 100644 --- a/src/main/java/com/urswolfer/gerrit/client/rest/http/changes/RevisionApiRestClient.java +++ b/src/main/java/com/urswolfer/gerrit/client/rest/http/changes/RevisionApiRestClient.java @@ -78,6 +78,11 @@ public void review(ReviewInput reviewInput) throws RestApiException { gerritRestClient.postRequest(request, json); } + // for verify-status-reporter plugin + public VerifyStatusApi verifyStatus() throws RestApiException { + return new VerifyStatusApiRestClient(gerritRestClient, this); + } + @Override public void submit() throws RestApiException { submit(new SubmitInput()); diff --git a/src/main/java/com/urswolfer/gerrit/client/rest/http/changes/VerifyStatusApiRestClient.java b/src/main/java/com/urswolfer/gerrit/client/rest/http/changes/VerifyStatusApiRestClient.java new file mode 100644 index 00000000..fbb00feb --- /dev/null +++ b/src/main/java/com/urswolfer/gerrit/client/rest/http/changes/VerifyStatusApiRestClient.java @@ -0,0 +1,40 @@ +// Copyright (C) 2016 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.urswolfer.gerrit.client.rest.http.changes; + +import com.google.gerrit.extensions.api.changes.*; +import com.google.gerrit.extensions.restapi.RestApiException; +import com.urswolfer.gerrit.client.rest.http.GerritRestClient; + +public class VerifyStatusApiRestClient extends VerifyStatusApi.NotImplemented + implements VerifyStatusApi { + + private final GerritRestClient gerritRestClient; + private final RevisionApiRestClient revisionApiRestClient; + + public VerifyStatusApiRestClient(GerritRestClient gerritRestClient, + RevisionApiRestClient revisionApiRestClient) { + this.gerritRestClient = gerritRestClient; + this.revisionApiRestClient = revisionApiRestClient; + } + + @Override + public void verifications(VerifyInput verifyInput) throws RestApiException { + String request = + revisionApiRestClient.getRequestPath() + "/verify-status~verifications"; + String json = gerritRestClient.getGson().toJson(verifyInput); + gerritRestClient.postRequest(request, json); + } +} \ No newline at end of file