Add GET /changes/*/detail endpoint

This contains more detailed change information than GET /changes/*, and
is intended to be used by the ChangeScreen.

Change-Id: Ia267a6db92b07fc5f08fa3506fab86d2a22ea452
This commit is contained in:
Dave Borowitz 2013-02-13 11:47:16 -08:00 committed by Gerrit Code Review
parent 675879a733
commit 38e6ff45eb
3 changed files with 40 additions and 0 deletions

View File

@ -61,6 +61,10 @@ public class ChangeApi {
}
}
public static void detail(int id, AsyncCallback<ChangeInfo> cb) {
call(id, "detail").get(cb);
}
public static RestApi revision(PatchSet.Id id) {
return change(id.getParentKey().get()).view("revisions").id(id.get());
}

View File

@ -0,0 +1,35 @@
// Copyright (C) 2013 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.server.change;
import com.google.gerrit.common.changes.ListChangesOption;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
public class GetDetail implements RestReadView<ChangeResource> {
private final ChangeJson json;
@Inject
GetDetail(ChangeJson json) {
this.json = json.addOption(ListChangesOption.DETAILED_LABELS)
.addOption(ListChangesOption.DETAILED_ACCOUNTS);
}
@Override
public Object apply(ChangeResource rsrc) throws OrmException {
return json.format(rsrc);
}
}

View File

@ -41,6 +41,7 @@ public class Module extends RestApiModule {
DynamicMap.mapOf(binder(), REVISION_KIND);
get(CHANGE_KIND).to(GetChange.class);
get(CHANGE_KIND, "detail").to(GetDetail.class);
get(CHANGE_KIND, "topic").to(GetTopic.class);
put(CHANGE_KIND, "topic").to(PutTopic.class);
delete(CHANGE_KIND, "topic").to(PutTopic.class);