use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.
the class ChangeApi method createChange.
/**
* Create a new change.
*
* <p>The new change is created as DRAFT unless the draft workflow is disabled by
* `change.allowDrafts = false` in the configuration, in which case the new change is created as
* NEW.
*/
public static void createChange(String project, String branch, String topic, String subject, String base, AsyncCallback<ChangeInfo> cb) {
CreateChangeInput input = CreateChangeInput.create();
input.project(emptyToNull(project));
input.branch(emptyToNull(branch));
input.topic(emptyToNull(topic));
input.subject(emptyToNull(subject));
input.baseChange(emptyToNull(base));
if (Gerrit.info().change().allowDrafts()) {
input.status(Change.Status.DRAFT.toString());
}
new RestApi("/changes/").post(input, cb);
}
use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.
the class ChangeList method query.
public static void query(String query, Set<ListChangesOption> options, AsyncCallback<ChangeList> callback, int start, int limit) {
RestApi call = newQuery(query);
if (limit > 0) {
call.addParameter("n", limit);
}
addOptions(call, options);
if (start != 0) {
call.addParameter("S", start);
}
call.get(callback);
}
use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.
the class ChangeList method queryMultiple.
/** Run multiple queries in a single remote invocation. */
public static void queryMultiple(final AsyncCallback<JsArray<ChangeList>> callback, Set<ListChangesOption> options, String... queries) {
if (queries.length == 0) {
return;
}
RestApi call = new RestApi(URI);
for (String q : queries) {
call.addParameterRaw("q", KeyUtil.encode(q));
}
addOptions(call, options);
if (queries.length == 1) {
// Server unwraps a single query, so wrap it back in an array for the
// callback.
call.get(new AsyncCallback<ChangeList>() {
@Override
public void onSuccess(ChangeList result) {
JsArray<ChangeList> wrapped = JsArray.createArray(1).cast();
wrapped.set(0, result);
callback.onSuccess(wrapped);
}
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
});
} else {
call.get(callback);
}
}
use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.
the class StarredChanges method startRequest.
private static void startRequest() {
busy = true;
final Change.Id id = pending.keySet().iterator().next();
final boolean starred = pending.remove(id);
RestApi call = AccountApi.self().view("starred.changes").id(id.get());
AsyncCallback<JavaScriptObject> cb = new AsyncCallback<JavaScriptObject>() {
@Override
public void onSuccess(JavaScriptObject none) {
if (pending.isEmpty()) {
busy = false;
} else {
startRequest();
}
}
@Override
public void onFailure(Throwable caught) {
if (!starred && RestApi.isStatus(caught, 404)) {
onSuccess(null);
return;
}
fireChangeStarEvent(id, !starred);
for (Map.Entry<Change.Id, Boolean> e : pending.entrySet()) {
fireChangeStarEvent(e.getKey(), !e.getValue());
}
pending.clear();
busy = false;
}
};
if (starred) {
call.put(cb);
} else {
call.delete(cb);
}
}
use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.
the class ConfigServerApi method confirmEmail.
public static void confirmEmail(String token, AsyncCallback<VoidResult> cb) {
EmailConfirmationInput input = EmailConfirmationInput.create();
input.setToken(token);
new RestApi("/config/server/email.confirm").put(input, cb);
}
Aggregations