forked from uwolfer/gerrit-rest-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Gerrit Verify Status REST endpoints
The gerrit-verify-status plugin provides additional Gerrit REST endpoints. This adds support for those endpoints[1]. This resolves issue uwolfer#59 [1] https://gerrit.googlesource.com/plugins/verify-status/+/master/src/main/resources/Documentation/rest-api-changes.md
- Loading branch information
Showing
6 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/com/google/gerrit/extensions/api/changes/VerifyInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String, VerificationInfo> verifications; | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/google/gerrit/extensions/api/changes/VerifyStatusApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/google/gerrit/extensions/common/VerificationInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/com/urswolfer/gerrit/client/rest/http/changes/VerifyStatusApiRestClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |