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

Support Gerrit Verify Status REST endpoints #60

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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 @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
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;
}
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();
}
}
}
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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
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);
}
}