Dissolve gerrit-extension-api top-level directory

Change-Id: I47a130d3203cf45ce09f2a44e81449c55eaa693b
This commit is contained in:
David Ostrovsky
2017-08-16 22:21:14 +02:00
committed by Dave Borowitz
parent 261187922d
commit 898832619a
338 changed files with 52 additions and 66 deletions

View File

@@ -0,0 +1,61 @@
load("//lib:guava.bzl", "GUAVA_DOC_URL")
load("//lib/jgit:jgit.bzl", "JGIT_DOC_URL")
load("//tools/bzl:gwt.bzl", "gwt_module")
SRCS = glob(["**/*.java"])
EXT_API_SRCS = glob(["client/*.java"])
gwt_module(
name = "client",
srcs = EXT_API_SRCS,
gwt_xml = "Extensions.gwt.xml",
visibility = ["//visibility:public"],
)
java_binary(
name = "extension-api",
main_class = "Dummy",
visibility = ["//visibility:public"],
runtime_deps = [":lib"],
)
java_library(
name = "lib",
visibility = ["//visibility:public"],
exports = [
":api",
"//lib:guava",
"//lib:servlet-api-3_1",
"//lib/guice",
"//lib/guice:guice-assistedinject",
"//lib/guice:guice-servlet",
],
)
#TODO(davido): There is no provided_deps argument to java_library rule
java_library(
name = "api",
srcs = glob(["**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//gerrit-common:annotations",
"//lib:guava",
"//lib/guice",
"//lib/guice:guice-assistedinject",
],
)
load("//tools/bzl:javadoc.bzl", "java_doc")
java_doc(
name = "extension-api-javadoc",
external_docs = [
JGIT_DOC_URL,
GUAVA_DOC_URL,
],
libs = [":api"],
pkgs = ["com.google.gerrit.extensions"],
title = "Gerrit Review Extension API Documentation",
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,18 @@
<!--
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.
-->
<module>
<source path='client' />
</module>

View File

@@ -0,0 +1,36 @@
// 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.extensions.annotations;
/** Declared scope of a capability named by {@link RequiresCapability}. */
public enum CapabilityScope {
/**
* Scope is assumed based on the context.
*
* <p>When {@code @RequiresCapability} is used within a plugin the scope of the capability is
* assumed to be that plugin.
*
* <p>If {@code @RequiresCapability} is used within the core Gerrit Code Review server (and thus
* is outside of a plugin) the scope is the core server and will use {@code
* com.google.gerrit.common.data.GlobalCapability}.
*/
CONTEXT,
/** Scope is only the plugin. */
PLUGIN,
/** Scope is the core server. */
CORE
}

View File

@@ -0,0 +1,50 @@
// Copyright (C) 2012 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.annotations;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import com.google.inject.BindingAnnotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Annotation applied to auto-registered, exported types.
*
* <p>Plugins or extensions using auto-registration should apply this annotation to any non-abstract
* class they want exported for access.
*
* <p>For SSH commands the {@literal @Export} annotation names the subcommand:
*
* <pre>
* {@literal @Export("print")}
* class MyCommand extends SshCommand {
* </pre>
*
* For HTTP servlets, the {@literal @Export} annotation names the URL the servlet is bound to,
* relative to the plugin or extension's namespace within the Gerrit container.
*
* <pre>
* {@literal @Export("/index.html")}
* class ShowIndexHtml extends HttpServlet {
* </pre>
*/
@Target({ElementType.TYPE})
@Retention(RUNTIME)
@BindingAnnotation
public @interface Export {
String value();
}

View File

@@ -0,0 +1,52 @@
// Copyright (C) 2012 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.annotations;
import java.io.Serializable;
import java.lang.annotation.Annotation;
final class ExportImpl implements Export, Serializable {
private static final long serialVersionUID = 0;
private final String value;
ExportImpl(String value) {
this.value = value;
}
@Override
public Class<? extends Annotation> annotationType() {
return Export.class;
}
@Override
public String value() {
return value;
}
@Override
public int hashCode() {
return (127 * "value".hashCode()) ^ value.hashCode();
}
@Override
public boolean equals(Object o) {
return o instanceof Export && value.equals(((Export) o).value());
}
@Override
public String toString() {
return "@" + Export.class.getName() + "(value=" + value + ")";
}
}

View File

@@ -0,0 +1,30 @@
// Copyright (C) 2012 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.annotations;
/** Static constructors for {@link Export} annotations. */
public final class Exports {
/** Create an annotation to export under a specific name. */
public static Export named(String name) {
return new ExportImpl(name);
}
/** Create an annotation to export based on a cannonical class name. */
public static Export named(Class<?> clazz) {
return named(clazz.getCanonicalName());
}
private Exports() {}
}

View File

@@ -0,0 +1,39 @@
// Copyright (C) 2012 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.annotations;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.inject.BindingAnnotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Annotation for interfaces that accept auto-registered implementations.
*
* <p>Interfaces that accept automatically registered implementations into their {@link DynamicSet}
* must be tagged with this annotation.
*
* <p>Plugins or extensions that implement an {@code @ExtensionPoint} interface should use the
* {@link Listen} annotation to automatically register.
*
* @see Listen
*/
@Target({ElementType.TYPE})
@Retention(RUNTIME)
@BindingAnnotation
public @interface ExtensionPoint {}

View File

@@ -0,0 +1,37 @@
// Copyright (C) 2012 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.annotations;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import com.google.inject.BindingAnnotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Annotation for auto-registered extension point implementations.
*
* <p>Plugins or extensions using auto-registration should apply this annotation to any non-abstract
* class that implements an unnamed extension point, such as a notification listener. Gerrit will
* automatically determine which extension points to apply based on the interfaces the type
* implements.
*
* @see Export
*/
@Target({ElementType.TYPE})
@Retention(RUNTIME)
@BindingAnnotation
public @interface Listen {}

View File

@@ -0,0 +1,40 @@
// 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.extensions.annotations;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import com.google.inject.BindingAnnotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Annotation applied to a String containing the plugin canonical web URL.
*
* <p>A plugin or extension may receive this string by Guice injection to discover the canonical web
* URL under which the plugin is available:
*
* <pre>
* {@literal @Inject}
* MyType(@PluginCanonicalWebUrl String myUrl) {
* ...
* }
* </pre>
*/
@Target({ElementType.PARAMETER, ElementType.FIELD})
@Retention(RUNTIME)
@BindingAnnotation
public @interface PluginCanonicalWebUrl {}

View File

@@ -0,0 +1,41 @@
// Copyright (C) 2012 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.annotations;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import com.google.inject.BindingAnnotation;
import java.lang.annotation.Retention;
/**
* Local path where a plugin can store its own private data.
*
* <p>A plugin or extension may receive this string by Guice injection to discover a directory where
* it can store configuration or other data that is private:
*
* <p>This binding is on both {@link java.io.File} and {@link java.nio.file.Path}, pointing to the
* same location. The {@code File} version should be considered deprecated and may be removed in a
* future version.
*
* <pre>
* {@literal @Inject}
* MyType(@PluginData java.nio.file.Path myDir) {
* this.in = Files.newInputStream(myDir.resolve(&quot;my.config&quot;));
* }
* </pre>
*/
@Retention(RUNTIME)
@BindingAnnotation
public @interface PluginData {}

View File

@@ -0,0 +1,40 @@
// Copyright (C) 2012 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.annotations;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import com.google.inject.BindingAnnotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Annotation applied to a String containing the plugin or extension name.
*
* <p>A plugin or extension may receive this string by Guice injection to discover the name that an
* administrator has installed the plugin or extension under:
*
* <pre>
* {@literal @Inject}
* MyType(@PluginName String myName) {
* ...
* }
* </pre>
*/
@Target({ElementType.PARAMETER, ElementType.FIELD})
@Retention(RUNTIME)
@BindingAnnotation
public @interface PluginName {}

View File

@@ -0,0 +1,39 @@
// 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.annotations;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Annotation on {@code com.google.gerrit.sshd.SshCommand} or {@code
* com.google.gerrit.httpd.restapi.RestApiServlet} declaring a set of capabilities of which at least
* one must be granted.
*/
@Target({ElementType.TYPE})
@Retention(RUNTIME)
public @interface RequiresAnyCapability {
/** Capabilities at least one of which is required to invoke this action. */
String[] value();
/** Scope of the named capabilities. */
CapabilityScope scope() default CapabilityScope.CONTEXT;
/** Fall back to admin credentials. Only applies to plugin capability check. */
boolean fallBackToAdmin() default true;
}

View File

@@ -0,0 +1,38 @@
// Copyright (C) 2012 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.annotations;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Annotation on {@code com.google.gerrit.sshd.SshCommand} or {@code
* com.google.gerrit.httpd.restapi.RestApiServlet} declaring a capability must be granted.
*/
@Target({ElementType.TYPE})
@Retention(RUNTIME)
public @interface RequiresCapability {
/** Name of the capability required to invoke this action. */
String value();
/** Scope of the named capability. */
CapabilityScope scope() default CapabilityScope.CONTEXT;
/** Fall back to admin credentials. Only applies to plugin capability check. */
boolean fallBackToAdmin() default true;
}

View File

@@ -0,0 +1,33 @@
// Copyright (C) 2014 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.annotations;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import com.google.inject.BindingAnnotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Annotation applied to HttpServletRequest and HttpServletResponse when they are inherited from
* Gerrit instead of being injected by a plugin's ServletModule. This means that the path returned
* by 'javax.servlet.http.HttpServletRequest#getPathInfo()' is relative to the Gerrit root instead
* of a path within the plugin's URL space.
*/
@Target({ElementType.PARAMETER, ElementType.FIELD})
@Retention(RUNTIME)
@BindingAnnotation
public @interface RootRelative {}

View File

@@ -0,0 +1,73 @@
// 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.extensions.api;
import com.google.gerrit.extensions.api.accounts.Accounts;
import com.google.gerrit.extensions.api.changes.Changes;
import com.google.gerrit.extensions.api.config.Config;
import com.google.gerrit.extensions.api.groups.Groups;
import com.google.gerrit.extensions.api.plugins.Plugins;
import com.google.gerrit.extensions.api.projects.Projects;
import com.google.gerrit.extensions.restapi.NotImplementedException;
public interface GerritApi {
Accounts accounts();
Changes changes();
Config config();
Groups groups();
Projects projects();
Plugins plugins();
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements GerritApi {
@Override
public Accounts accounts() {
throw new NotImplementedException();
}
@Override
public Changes changes() {
throw new NotImplementedException();
}
@Override
public Config config() {
throw new NotImplementedException();
}
@Override
public Groups groups() {
throw new NotImplementedException();
}
@Override
public Projects projects() {
throw new NotImplementedException();
}
@Override
public Plugins plugins() {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,35 @@
// 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.access;
import java.util.Map;
import java.util.Objects;
public class AccessSectionInfo {
public Map<String, PermissionInfo> permissions;
@Override
public boolean equals(Object obj) {
if (obj instanceof AccessSectionInfo) {
return Objects.equals(permissions, ((AccessSectionInfo) obj).permissions);
}
return false;
}
@Override
public int hashCode() {
return Objects.hash(permissions);
}
}

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2017 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.access;
/**
* A {@link com.google.gerrit.server.permissions.GlobalPermission} or a {@link PluginPermission}.
*/
public interface GlobalOrPluginPermission {
/** @return name used in {@code project.config} permissions. */
public String permissionName();
/** @return readable identifier of this permission for exception message. */
public String describeForException();
}

View File

@@ -0,0 +1,44 @@
// 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.access;
import java.util.Map;
import java.util.Objects;
public class PermissionInfo {
public String label;
public Boolean exclusive;
public Map<String, PermissionRuleInfo> rules;
public PermissionInfo(String label, Boolean exclusive) {
this.label = label;
this.exclusive = exclusive;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof PermissionInfo) {
PermissionInfo p = (PermissionInfo) obj;
return Objects.equals(label, p.label)
&& Objects.equals(exclusive, p.exclusive)
&& Objects.equals(rules, p.rules);
}
return false;
}
@Override
public int hashCode() {
return Objects.hash(label, exclusive, rules);
}
}

View File

@@ -0,0 +1,53 @@
// 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.access;
import java.util.Objects;
public class PermissionRuleInfo {
public enum Action {
ALLOW,
DENY,
BLOCK,
INTERACTIVE,
BATCH
}
public Action action;
public Boolean force;
public Integer min;
public Integer max;
public PermissionRuleInfo(Action action, Boolean force) {
this.action = action;
this.force = force;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof PermissionRuleInfo) {
PermissionRuleInfo p = (PermissionRuleInfo) obj;
return Objects.equals(action, p.action)
&& Objects.equals(force, p.force)
&& Objects.equals(min, p.min)
&& Objects.equals(max, p.max);
}
return false;
}
@Override
public int hashCode() {
return Objects.hash(action, force, min, max);
}
}

View File

@@ -0,0 +1,77 @@
// Copyright (C) 2017 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.access;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
/** A global capability type permission used by a plugin. */
public class PluginPermission implements GlobalOrPluginPermission {
private final String pluginName;
private final String capability;
private final boolean fallBackToAdmin;
public PluginPermission(String pluginName, String capability) {
this(pluginName, capability, true);
}
public PluginPermission(String pluginName, String capability, boolean fallBackToAdmin) {
this.pluginName = checkNotNull(pluginName, "pluginName");
this.capability = checkNotNull(capability, "capability");
this.fallBackToAdmin = fallBackToAdmin;
}
public String pluginName() {
return pluginName;
}
public String capability() {
return capability;
}
public boolean fallBackToAdmin() {
return fallBackToAdmin;
}
@Override
public String permissionName() {
return pluginName + '-' + capability;
}
@Override
public String describeForException() {
return capability + " for plugin " + pluginName;
}
@Override
public int hashCode() {
return Objects.hash(pluginName, capability);
}
@Override
public boolean equals(Object other) {
if (other instanceof PluginPermission) {
PluginPermission b = (PluginPermission) other;
return pluginName.equals(b.pluginName) && capability.equals(b.capability);
}
return false;
}
@Override
public String toString() {
return "PluginPermission[plugin=" + pluginName + ", capability=" + capability + ']';
}
}

View File

@@ -0,0 +1,32 @@
// 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.access;
import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.common.ProjectInfo;
import java.util.Map;
import java.util.Set;
public class ProjectAccessInfo {
public String revision;
public ProjectInfo inheritsFrom;
public Map<String, AccessSectionInfo> local;
public Boolean isOwner;
public Set<String> ownerOf;
public Boolean canUpload;
public Boolean canAdd;
public Boolean configVisible;
public Map<String, GroupInfo> groups;
}

View File

@@ -0,0 +1,23 @@
// 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.access;
import java.util.Map;
public class ProjectAccessInput {
public Map<String, AccessSectionInfo> remove;
public Map<String, AccessSectionInfo> add;
public String parent;
public String message;
}

View File

@@ -0,0 +1,283 @@
// Copyright (C) 2014 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.accounts;
import com.google.gerrit.extensions.api.changes.StarsInput;
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gerrit.extensions.client.EditPreferencesInfo;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
import com.google.gerrit.extensions.client.ProjectWatchInfo;
import com.google.gerrit.extensions.common.AccountExternalIdInfo;
import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.extensions.common.AgreementInfo;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.EmailInfo;
import com.google.gerrit.extensions.common.GpgKeyInfo;
import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.common.SshKeyInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
public interface AccountApi {
AccountInfo get() throws RestApiException;
boolean getActive() throws RestApiException;
void setActive(boolean active) throws RestApiException;
String getAvatarUrl(int size) throws RestApiException;
GeneralPreferencesInfo getPreferences() throws RestApiException;
GeneralPreferencesInfo setPreferences(GeneralPreferencesInfo in) throws RestApiException;
DiffPreferencesInfo getDiffPreferences() throws RestApiException;
DiffPreferencesInfo setDiffPreferences(DiffPreferencesInfo in) throws RestApiException;
EditPreferencesInfo getEditPreferences() throws RestApiException;
EditPreferencesInfo setEditPreferences(EditPreferencesInfo in) throws RestApiException;
List<ProjectWatchInfo> getWatchedProjects() throws RestApiException;
List<ProjectWatchInfo> setWatchedProjects(List<ProjectWatchInfo> in) throws RestApiException;
void deleteWatchedProjects(List<ProjectWatchInfo> in) throws RestApiException;
void starChange(String changeId) throws RestApiException;
void unstarChange(String changeId) throws RestApiException;
void setStars(String changeId, StarsInput input) throws RestApiException;
SortedSet<String> getStars(String changeId) throws RestApiException;
List<ChangeInfo> getStarredChanges() throws RestApiException;
List<GroupInfo> getGroups() throws RestApiException;
List<EmailInfo> getEmails() throws RestApiException;
void addEmail(EmailInput input) throws RestApiException;
void deleteEmail(String email) throws RestApiException;
void setStatus(String status) throws RestApiException;
List<SshKeyInfo> listSshKeys() throws RestApiException;
SshKeyInfo addSshKey(String key) throws RestApiException;
void deleteSshKey(int seq) throws RestApiException;
Map<String, GpgKeyInfo> listGpgKeys() throws RestApiException;
Map<String, GpgKeyInfo> putGpgKeys(List<String> add, List<String> remove) throws RestApiException;
GpgKeyApi gpgKey(String id) throws RestApiException;
List<AgreementInfo> listAgreements() throws RestApiException;
void signAgreement(String agreementName) throws RestApiException;
void index() throws RestApiException;
List<AccountExternalIdInfo> getExternalIds() throws RestApiException;
void deleteExternalIds(List<String> externalIds) throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements AccountApi {
@Override
public AccountInfo get() throws RestApiException {
throw new NotImplementedException();
}
@Override
public boolean getActive() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void setActive(boolean active) throws RestApiException {
throw new NotImplementedException();
}
@Override
public String getAvatarUrl(int size) throws RestApiException {
throw new NotImplementedException();
}
@Override
public GeneralPreferencesInfo getPreferences() throws RestApiException {
throw new NotImplementedException();
}
@Override
public GeneralPreferencesInfo setPreferences(GeneralPreferencesInfo in)
throws RestApiException {
throw new NotImplementedException();
}
@Override
public DiffPreferencesInfo getDiffPreferences() throws RestApiException {
throw new NotImplementedException();
}
@Override
public DiffPreferencesInfo setDiffPreferences(DiffPreferencesInfo in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public EditPreferencesInfo getEditPreferences() throws RestApiException {
throw new NotImplementedException();
}
@Override
public EditPreferencesInfo setEditPreferences(EditPreferencesInfo in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<ProjectWatchInfo> getWatchedProjects() throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<ProjectWatchInfo> setWatchedProjects(List<ProjectWatchInfo> in)
throws RestApiException {
throw new NotImplementedException();
}
@Override
public void deleteWatchedProjects(List<ProjectWatchInfo> in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void starChange(String changeId) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void unstarChange(String changeId) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void setStars(String changeId, StarsInput input) throws RestApiException {
throw new NotImplementedException();
}
@Override
public SortedSet<String> getStars(String changeId) throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<ChangeInfo> getStarredChanges() throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<GroupInfo> getGroups() throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<EmailInfo> getEmails() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void addEmail(EmailInput input) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void deleteEmail(String email) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void setStatus(String status) throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<SshKeyInfo> listSshKeys() throws RestApiException {
throw new NotImplementedException();
}
@Override
public SshKeyInfo addSshKey(String key) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void deleteSshKey(int seq) throws RestApiException {
throw new NotImplementedException();
}
@Override
public Map<String, GpgKeyInfo> putGpgKeys(List<String> add, List<String> remove)
throws RestApiException {
throw new NotImplementedException();
}
@Override
public GpgKeyApi gpgKey(String id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public Map<String, GpgKeyInfo> listGpgKeys() throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<AgreementInfo> listAgreements() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void signAgreement(String agreementName) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void index() throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<AccountExternalIdInfo> getExternalIds() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void deleteExternalIds(List<String> externalIds) throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,27 @@
// 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.accounts;
import com.google.gerrit.extensions.restapi.DefaultInput;
import java.util.List;
public class AccountInput {
@DefaultInput public String username;
public String name;
public String email;
public String sshKey;
public String httpPassword;
public List<String> groups;
}

View File

@@ -0,0 +1,251 @@
// Copyright (C) 2014 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.accounts;
import com.google.gerrit.extensions.client.ListAccountsOption;
import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
public interface Accounts {
/**
* Look up an account by ID.
*
* <p><strong>Note:</strong> This method eagerly reads the account. Methods that mutate the
* account do not necessarily re-read the account. Therefore, calling a getter method on an
* instance after calling a mutation method on that same instance is not guaranteed to reflect the
* mutation. It is not recommended to store references to {@code AccountApi} instances.
*
* @param id any identifier supported by the REST API, including numeric ID, email, or username.
* @return API for accessing the account.
* @throws RestApiException if an error occurred.
*/
AccountApi id(String id) throws RestApiException;
/** @see #id(String) */
AccountApi id(int id) throws RestApiException;
/**
* Look up the account of the current in-scope user.
*
* @see #id(String)
*/
AccountApi self() throws RestApiException;
/** Create a new account with the given username and default options. */
AccountApi create(String username) throws RestApiException;
/** Create a new account. */
AccountApi create(AccountInput input) throws RestApiException;
/**
* Suggest users for a given query.
*
* <p>Example code: {@code suggestAccounts().withQuery("Reviewer").withLimit(5).get()}
*
* @return API for setting parameters and getting result.
*/
SuggestAccountsRequest suggestAccounts() throws RestApiException;
/**
* Suggest users for a given query.
*
* <p>Shortcut API for {@code suggestAccounts().withQuery(String)}.
*
* @see #suggestAccounts()
*/
SuggestAccountsRequest suggestAccounts(String query) throws RestApiException;
/**
* Query users.
*
* <p>Example code: {@code query().withQuery("name:John email:example.com").withLimit(5).get()}
*
* @return API for setting parameters and getting result.
*/
QueryRequest query() throws RestApiException;
/**
* Query users.
*
* <p>Shortcut API for {@code query().withQuery(String)}.
*
* @see #query()
*/
QueryRequest query(String query) throws RestApiException;
/**
* API for setting parameters and getting result. Used for {@code suggestAccounts()}.
*
* @see #suggestAccounts()
*/
abstract class SuggestAccountsRequest {
private String query;
private int limit;
/** Execute query and return a list of accounts. */
public abstract List<AccountInfo> get() throws RestApiException;
/**
* Set query.
*
* @param query needs to be in human-readable form.
*/
public SuggestAccountsRequest withQuery(String query) {
this.query = query;
return this;
}
/**
* Set limit for returned list of accounts. Optional; server-default is used when not provided.
*/
public SuggestAccountsRequest withLimit(int limit) {
this.limit = limit;
return this;
}
public String getQuery() {
return query;
}
public int getLimit() {
return limit;
}
}
/**
* API for setting parameters and getting result. Used for {@code query()}.
*
* @see #query()
*/
abstract class QueryRequest {
private String query;
private int limit;
private int start;
private EnumSet<ListAccountsOption> options = EnumSet.noneOf(ListAccountsOption.class);
/** Execute query and return a list of accounts. */
public abstract List<AccountInfo> get() throws RestApiException;
/**
* Set query.
*
* @param query needs to be in human-readable form.
*/
public QueryRequest withQuery(String query) {
this.query = query;
return this;
}
/**
* Set limit for returned list of accounts. Optional; server-default is used when not provided.
*/
public QueryRequest withLimit(int limit) {
this.limit = limit;
return this;
}
/** Set number of accounts to skip. Optional; no accounts are skipped when not provided. */
public QueryRequest withStart(int start) {
this.start = start;
return this;
}
public QueryRequest withOption(ListAccountsOption options) {
this.options.add(options);
return this;
}
public QueryRequest withOptions(ListAccountsOption... options) {
this.options.addAll(Arrays.asList(options));
return this;
}
public QueryRequest withOptions(EnumSet<ListAccountsOption> options) {
this.options = options;
return this;
}
public String getQuery() {
return query;
}
public int getLimit() {
return limit;
}
public int getStart() {
return start;
}
public EnumSet<ListAccountsOption> getOptions() {
return options;
}
}
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements Accounts {
@Override
public AccountApi id(String id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public AccountApi id(int id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public AccountApi self() throws RestApiException {
throw new NotImplementedException();
}
@Override
public AccountApi create(String username) throws RestApiException {
throw new NotImplementedException();
}
@Override
public AccountApi create(AccountInput input) throws RestApiException {
throw new NotImplementedException();
}
@Override
public SuggestAccountsRequest suggestAccounts() throws RestApiException {
throw new NotImplementedException();
}
@Override
public SuggestAccountsRequest suggestAccounts(String query) throws RestApiException {
throw new NotImplementedException();
}
@Override
public QueryRequest query() throws RestApiException {
throw new NotImplementedException();
}
@Override
public QueryRequest query(String query) throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,33 @@
// 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.accounts;
import com.google.gerrit.extensions.restapi.DefaultInput;
/** This entity contains information for registering a new email address. */
public class EmailInput {
/* The email address. If provided, must match the email address from the URL. */
@DefaultInput public String email;
/* Whether the new email address should become the preferred email address of
* the user. Only supported if {@link #noConfirmation} is set or if the
* authentication type is DEVELOPMENT_BECOME_ANY_ACCOUNT.*/
public boolean preferred;
/* Whether the email address should be added without confirmation. In this
* case no verification email is sent to the user. Only Gerrit administrators
* are allowed to add email addresses without confirmation. */
public boolean noConfirmation;
}

View File

@@ -0,0 +1,41 @@
// 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.accounts;
import com.google.gerrit.extensions.common.GpgKeyInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
public interface GpgKeyApi {
GpgKeyInfo get() throws RestApiException;
void delete() throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements GpgKeyApi {
@Override
public GpgKeyInfo get() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void delete() throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,22 @@
// Copyright (C) 2017 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.accounts;
import java.util.List;
public class GpgKeysInput {
public List<String> add;
public List<String> delete;
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2017 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.accounts;
import com.google.gerrit.extensions.restapi.RawInput;
public class SshKeyInput {
public RawInput raw;
}

View File

@@ -0,0 +1,27 @@
// Copyright (C) 2017 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.accounts;
import com.google.gerrit.extensions.restapi.DefaultInput;
public class StatusInput {
public @DefaultInput String status;
public StatusInput(String status) {
this.status = status;
}
public StatusInput() {}
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2017 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.accounts;
import com.google.gerrit.extensions.restapi.DefaultInput;
public class UsernameInput {
@DefaultInput public String username;
}

View File

@@ -0,0 +1,24 @@
// 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.extensions.api.changes;
import com.google.gerrit.extensions.restapi.DefaultInput;
import java.util.Map;
public class AbandonInput {
@DefaultInput public String message;
public NotifyHandling notify;
public Map<RecipientType, NotifyInfo> notifyDetails;
}

View File

@@ -0,0 +1,62 @@
// 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.annotations.ExtensionPoint;
import com.google.gerrit.extensions.common.ActionInfo;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.RevisionInfo;
/**
* Extension point called during population of {@link ActionInfo} maps.
*
* <p>Each visitor may mutate the input {@link ActionInfo}, or filter it out of the map entirely.
* When multiple extensions are registered, the order in which they are executed is undefined.
*/
@ExtensionPoint
public interface ActionVisitor {
/**
* Visit a change-level action.
*
* <p>Callers may mutate the input {@link ActionInfo}, or return false to omit the action from the
* map entirely. Inputs other than the {@link ActionInfo} should be considered immutable.
*
* @param name name of the action, as a key into the {@link ActionInfo} map returned by the REST
* API.
* @param actionInfo action being visited; caller may mutate.
* @param changeInfo information about the change to which this action belongs; caller should
* treat as immutable.
* @return true if the action should remain in the map, or false to omit it.
*/
boolean visit(String name, ActionInfo actionInfo, ChangeInfo changeInfo);
/**
* Visit a revision-level action.
*
* <p>Callers may mutate the input {@link ActionInfo}, or return false to omit the action from the
* map entirely. Inputs other than the {@link ActionInfo} should be considered immutable.
*
* @param name name of the action, as a key into the {@link ActionInfo} map returned by the REST
* API.
* @param actionInfo action being visited; caller may mutate.
* @param changeInfo information about the change to which this action belongs; caller should
* treat as immutable.
* @param revisionInfo information about the revision to which this action belongs; caller should
* treat as immutable.
* @return true if the action should remain in the map, or false to omit it.
*/
boolean visit(
String name, ActionInfo actionInfo, ChangeInfo changeInfo, RevisionInfo revisionInfo);
}

View File

@@ -0,0 +1,37 @@
// 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.extensions.api.changes;
import static com.google.gerrit.extensions.client.ReviewerState.REVIEWER;
import com.google.gerrit.extensions.client.ReviewerState;
import com.google.gerrit.extensions.restapi.DefaultInput;
import java.util.Map;
public class AddReviewerInput {
@DefaultInput public String reviewer;
public Boolean confirmed;
public ReviewerState state;
public NotifyHandling notify;
public Map<RecipientType, NotifyInfo> notifyDetails;
public boolean confirmed() {
return (confirmed != null) ? confirmed : false;
}
public ReviewerState state() {
return (state != null) ? state : REVIEWER;
}
}

View File

@@ -0,0 +1,76 @@
// 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.common.Nullable;
import com.google.gerrit.extensions.common.AccountInfo;
import java.util.List;
/** Result object representing the outcome of a request to add a reviewer. */
public class AddReviewerResult {
/** The identifier of an account or group that was to be added as a reviewer. */
public String input;
/** If non-null, a string describing why the reviewer could not be added. */
@Nullable public String error;
/**
* Non-null and true if the reviewer cannot be added without explicit confirmation. This may be
* the case for groups of a certain size.
*/
@Nullable public Boolean confirm;
/**
* List of individual reviewers added to the change. The size of this list may be greater than one
* (e.g. when a group is added). Null if no reviewers were added.
*/
@Nullable public List<ReviewerInfo> reviewers;
/**
* List of accounts CCed on the change. The size of this list may be greater than one (e.g. when a
* group is CCed). Null if no accounts were CCed or if reviewers is non-null.
*/
@Nullable public List<AccountInfo> ccs;
/**
* Constructs a partially initialized result for the given reviewer.
*
* @param input String identifier of an account or group, from user request
*/
public AddReviewerResult(String input) {
this.input = input;
}
/**
* Constructs an error result for the given account.
*
* @param reviewer String identifier of an account or group
* @param error Error message
*/
public AddReviewerResult(String reviewer, String error) {
this(reviewer);
this.error = error;
}
/**
* Constructs a needs-confirmation result for the given account.
*
* @param confirm Whether confirmation is needed.
*/
public AddReviewerResult(String reviewer, boolean confirm) {
this(reviewer);
this.confirm = confirm;
}
}

View File

@@ -0,0 +1,21 @@
// 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.DefaultInput;
public class AssigneeInput {
@DefaultInput public String assignee;
}

View File

@@ -0,0 +1,594 @@
// 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.extensions.api.changes;
import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.client.ListChangesOption;
import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.CommentInfo;
import com.google.gerrit.extensions.common.CommitMessageInput;
import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.MergePatchSetInput;
import com.google.gerrit.extensions.common.PureRevertInfo;
import com.google.gerrit.extensions.common.RobotCommentInfo;
import com.google.gerrit.extensions.common.SuggestedReviewerInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public interface ChangeApi {
String id();
/**
* Look up the current revision for the change.
*
* <p><strong>Note:</strong> This method eagerly reads the revision. Methods that mutate the
* revision do not necessarily re-read the revision. Therefore, calling a getter method on an
* instance after calling a mutation method on that same instance is not guaranteed to reflect the
* mutation. It is not recommended to store references to {@code RevisionApi} instances.
*
* @return API for accessing the revision.
* @throws RestApiException if an error occurred.
*/
RevisionApi current() throws RestApiException;
/**
* Look up a revision of a change by number.
*
* @see #current()
*/
RevisionApi revision(int id) throws RestApiException;
/**
* Look up a revision of a change by commit SHA-1.
*
* @see #current()
*/
RevisionApi revision(String id) throws RestApiException;
/**
* Look up the reviewer of the change.
*
* <p>
*
* @param id ID of the account, can be a string of the format "Full Name
* &lt;mail@example.com&gt;", just the email address, a full name if it is unique, an account
* ID, a user name or 'self' for the calling user.
* @return API for accessing the reviewer.
* @throws RestApiException if id is not account ID or is a user that isn't known to be a reviewer
* for this change.
*/
ReviewerApi reviewer(String id) throws RestApiException;
void abandon() throws RestApiException;
void abandon(AbandonInput in) throws RestApiException;
void restore() throws RestApiException;
void restore(RestoreInput in) throws RestApiException;
void move(String destination) throws RestApiException;
void move(MoveInput in) throws RestApiException;
void setPrivate(boolean value, @Nullable String message) throws RestApiException;
void setWorkInProgress(String message) throws RestApiException;
void setReadyForReview(String message) throws RestApiException;
default void setWorkInProgress() throws RestApiException {
setWorkInProgress(null);
}
default void setReadyForReview() throws RestApiException {
setReadyForReview(null);
}
/**
* Ignore or un-ignore this change.
*
* @param ignore ignore the change if true
*/
void ignore(boolean ignore) throws RestApiException;
/**
* Check if this change is ignored.
*
* @return true if the change is ignored
*/
boolean ignored() throws RestApiException;
/**
* Mark this change as reviewed/unreviewed.
*
* @param reviewed flag to decide if this change should be marked as reviewed ({@code true}) or
* unreviewed ({@code false})
*/
void markAsReviewed(boolean reviewed) throws RestApiException;
/**
* Create a new change that reverts this change.
*
* @see Changes#id(int)
*/
ChangeApi revert() throws RestApiException;
/**
* Create a new change that reverts this change.
*
* @see Changes#id(int)
*/
ChangeApi revert(RevertInput in) throws RestApiException;
/** Create a merge patch set for the change. */
ChangeInfo createMergePatchSet(MergePatchSetInput in) throws RestApiException;
List<ChangeInfo> submittedTogether() throws RestApiException;
SubmittedTogetherInfo submittedTogether(EnumSet<SubmittedTogetherOption> options)
throws RestApiException;
SubmittedTogetherInfo submittedTogether(
EnumSet<ListChangesOption> listOptions, EnumSet<SubmittedTogetherOption> submitOptions)
throws RestApiException;
/** Publishes a draft change. */
@Deprecated
void publish() throws RestApiException;
/** Rebase the current revision of a change using default options. */
void rebase() throws RestApiException;
/** Rebase the current revision of a change. */
void rebase(RebaseInput in) throws RestApiException;
/** Deletes a change. */
void delete() throws RestApiException;
String topic() throws RestApiException;
void topic(String topic) throws RestApiException;
IncludedInInfo includedIn() throws RestApiException;
AddReviewerResult addReviewer(AddReviewerInput in) throws RestApiException;
AddReviewerResult addReviewer(String in) throws RestApiException;
SuggestedReviewersRequest suggestReviewers() throws RestApiException;
SuggestedReviewersRequest suggestReviewers(String query) throws RestApiException;
ChangeInfo get(EnumSet<ListChangesOption> options) throws RestApiException;
default ChangeInfo get(Iterable<ListChangesOption> options) throws RestApiException {
return get(Sets.newEnumSet(options, ListChangesOption.class));
}
default ChangeInfo get(ListChangesOption... options) throws RestApiException {
return get(Arrays.asList(options));
}
/** {@code get} with {@link ListChangesOption} set to all except CHECK. */
ChangeInfo get() throws RestApiException;
/** {@code get} with {@link ListChangesOption} set to none. */
ChangeInfo info() throws RestApiException;
/**
* Retrieve change edit when exists.
*
* @deprecated Replaced by {@link ChangeApi#edit()} in combination with {@link
* ChangeEditApi#get()}.
*/
@Deprecated
EditInfo getEdit() throws RestApiException;
/**
* Provides access to an API regarding the change edit of this change.
*
* @return a {@code ChangeEditApi} for the change edit of this change
* @throws RestApiException if the API isn't accessible
*/
ChangeEditApi edit() throws RestApiException;
/** Create a new patch set with a new commit message. */
void setMessage(String message) throws RestApiException;
/** Create a new patch set with a new commit message. */
void setMessage(CommitMessageInput in) throws RestApiException;
/** Set hashtags on a change */
void setHashtags(HashtagsInput input) throws RestApiException;
/**
* Get hashtags on a change.
*
* @return hashtags
* @throws RestApiException
*/
Set<String> getHashtags() throws RestApiException;
/** Set the assignee of a change. */
AccountInfo setAssignee(AssigneeInput input) throws RestApiException;
/** Get the assignee of a change. */
AccountInfo getAssignee() throws RestApiException;
/** Get all past assignees. */
List<AccountInfo> getPastAssignees() throws RestApiException;
/**
* Delete the assignee of a change.
*
* @return the assignee that was deleted, or null if there was no assignee.
*/
AccountInfo deleteAssignee() throws RestApiException;
/**
* Get all published comments on a change.
*
* @return comments in a map keyed by path; comments have the {@code revision} field set to
* indicate their patch set.
* @throws RestApiException
*/
Map<String, List<CommentInfo>> comments() throws RestApiException;
/**
* Get all robot comments on a change.
*
* @return robot comments in a map keyed by path; robot comments have the {@code revision} field
* set to indicate their patch set.
* @throws RestApiException
*/
Map<String, List<RobotCommentInfo>> robotComments() throws RestApiException;
/**
* Get all draft comments for the current user on a change.
*
* @return drafts in a map keyed by path; comments have the {@code revision} field set to indicate
* their patch set.
* @throws RestApiException
*/
Map<String, List<CommentInfo>> drafts() throws RestApiException;
ChangeInfo check() throws RestApiException;
ChangeInfo check(FixInput fix) throws RestApiException;
void index() throws RestApiException;
/** Check if this change is a pure revert of the change stored in revertOf. */
PureRevertInfo pureRevert() throws RestApiException;
/** Check if this change is a pure revert of claimedOriginal (SHA1 in 40 digit hex). */
PureRevertInfo pureRevert(String claimedOriginal) throws RestApiException;
abstract class SuggestedReviewersRequest {
private String query;
private int limit;
public abstract List<SuggestedReviewerInfo> get() throws RestApiException;
public SuggestedReviewersRequest withQuery(String query) {
this.query = query;
return this;
}
public SuggestedReviewersRequest withLimit(int limit) {
this.limit = limit;
return this;
}
public String getQuery() {
return query;
}
public int getLimit() {
return limit;
}
}
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements ChangeApi {
@Override
public String id() {
throw new NotImplementedException();
}
@Override
public RevisionApi current() throws RestApiException {
throw new NotImplementedException();
}
@Override
public RevisionApi revision(int id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public ReviewerApi reviewer(String id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public RevisionApi revision(String id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void abandon() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void abandon(AbandonInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void restore() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void restore(RestoreInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void move(String destination) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void move(MoveInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void setPrivate(boolean value, @Nullable String message) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void setWorkInProgress(String message) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void setReadyForReview(String message) throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeApi revert() throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeApi revert(RevertInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void publish() throws RestApiException {
throw new NotImplementedException();
}
@Deprecated
@Override
public void rebase() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void rebase(RebaseInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void delete() throws RestApiException {
throw new NotImplementedException();
}
@Override
public String topic() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void topic(String topic) throws RestApiException {
throw new NotImplementedException();
}
@Override
public IncludedInInfo includedIn() throws RestApiException {
throw new NotImplementedException();
}
@Override
public AddReviewerResult addReviewer(AddReviewerInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public AddReviewerResult addReviewer(String in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public SuggestedReviewersRequest suggestReviewers() throws RestApiException {
throw new NotImplementedException();
}
@Override
public SuggestedReviewersRequest suggestReviewers(String query) throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeInfo get(EnumSet<ListChangesOption> options) throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeInfo get() throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeInfo info() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void setMessage(String message) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void setMessage(CommitMessageInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public EditInfo getEdit() throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeEditApi edit() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void setHashtags(HashtagsInput input) throws RestApiException {
throw new NotImplementedException();
}
@Override
public Set<String> getHashtags() throws RestApiException {
throw new NotImplementedException();
}
@Override
public AccountInfo setAssignee(AssigneeInput input) throws RestApiException {
throw new NotImplementedException();
}
@Override
public AccountInfo getAssignee() throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<AccountInfo> getPastAssignees() throws RestApiException {
throw new NotImplementedException();
}
@Override
public AccountInfo deleteAssignee() throws RestApiException {
throw new NotImplementedException();
}
@Override
public Map<String, List<CommentInfo>> comments() throws RestApiException {
throw new NotImplementedException();
}
@Override
public Map<String, List<RobotCommentInfo>> robotComments() throws RestApiException {
throw new NotImplementedException();
}
@Override
public Map<String, List<CommentInfo>> drafts() throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeInfo check() throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeInfo check(FixInput fix) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void index() throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<ChangeInfo> submittedTogether() throws RestApiException {
throw new NotImplementedException();
}
@Override
public SubmittedTogetherInfo submittedTogether(EnumSet<SubmittedTogetherOption> options)
throws RestApiException {
throw new NotImplementedException();
}
@Override
public SubmittedTogetherInfo submittedTogether(
EnumSet<ListChangesOption> a, EnumSet<SubmittedTogetherOption> b) throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeInfo createMergePatchSet(MergePatchSetInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void ignore(boolean ignore) throws RestApiException {
throw new NotImplementedException();
}
@Override
public boolean ignored() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void markAsReviewed(boolean reviewed) throws RestApiException {
throw new NotImplementedException();
}
@Override
public PureRevertInfo pureRevert() throws RestApiException {
throw new NotImplementedException();
}
@Override
public PureRevertInfo pureRevert(String claimedOriginal) throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,223 @@
// Copyright (C) 2017 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.EditInfo;
import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RawInput;
import com.google.gerrit.extensions.restapi.RestApiException;
import java.util.Optional;
/**
* An API for the change edit of a change. A change edit is similar to a patch set and will become
* one if it is published (by {@link #publish(PublishChangeEditInput)}). Whenever the descriptions
* below refer to files of a change edit, they actually refer to the files of the Git tree which is
* represented by the change edit. A change can have at most one change edit at each point in time.
*/
public interface ChangeEditApi {
/**
* Retrieves details regarding the change edit.
*
* @return an {@code Optional} containing details about the change edit if it exists, or {@code
* Optional.empty()}
* @throws RestApiException if the change edit couldn't be retrieved
*/
Optional<EditInfo> get() throws RestApiException;
/**
* Creates a new change edit. It has exactly the same Git tree as the current patch set of the
* change.
*
* @throws RestApiException if the change edit couldn't be created or a change edit already exists
*/
void create() throws RestApiException;
/**
* Deletes the change edit.
*
* @throws RestApiException if the change edit couldn't be deleted or a change edit wasn't present
*/
void delete() throws RestApiException;
/**
* Rebases the change edit on top of the latest patch set of this change.
*
* @throws RestApiException if the change edit couldn't be rebased or a change edit wasn't present
*/
void rebase() throws RestApiException;
/**
* Publishes the change edit using default settings. See {@link #publish(PublishChangeEditInput)}
* for more details.
*
* @throws RestApiException if the change edit couldn't be published or a change edit wasn't
* present
*/
void publish() throws RestApiException;
/**
* Publishes the change edit. Publishing means that the change edit is turned into a regular patch
* set of the change.
*
* @param publishChangeEditInput a {@code PublishChangeEditInput} specifying the options which
* should be applied
* @throws RestApiException if the change edit couldn't be published or a change edit wasn't
* present
*/
void publish(PublishChangeEditInput publishChangeEditInput) throws RestApiException;
/**
* Retrieves the contents of the specified file from the change edit.
*
* @param filePath the path of the file
* @return an {@code Optional} containing the contents of the file as a {@code BinaryResult} if
* the file exists within the change edit, or {@code Optional.empty()}
* @throws RestApiException if the contents of the file couldn't be retrieved or a change edit
* wasn't present
*/
Optional<BinaryResult> getFile(String filePath) throws RestApiException;
/**
* Renames a file of the change edit or moves the file to another directory. If the change edit
* doesn't exist, it will be created based on the current patch set of the change.
*
* @param oldFilePath the current file path
* @param newFilePath the desired file path
* @throws RestApiException if the file couldn't be renamed
*/
void renameFile(String oldFilePath, String newFilePath) throws RestApiException;
/**
* Restores a file of the change edit to the state in which it was before the patch set on which
* the change edit is based. This includes the file content as well as the existence or
* non-existence of the file. If the change edit doesn't exist, it will be created based on the
* current patch set of the change.
*
* @param filePath the path of the file
* @throws RestApiException if the file couldn't be restored to its previous state
*/
void restoreFile(String filePath) throws RestApiException;
/**
* Modify the contents of the specified file of the change edit. If no content is provided, the
* content of the file is erased but the file isn't deleted. If the change edit doesn't exist, it
* will be created based on the current patch set of the change.
*
* @param filePath the path of the file which should be modified
* @param newContent the desired content of the file
* @throws RestApiException if the content of the file couldn't be modified
*/
void modifyFile(String filePath, RawInput newContent) throws RestApiException;
/**
* Deletes the specified file from the change edit. If the change edit doesn't exist, it will be
* created based on the current patch set of the change.
*
* @param filePath the path fo the file which should be deleted
* @throws RestApiException if the file couldn't be deleted
*/
void deleteFile(String filePath) throws RestApiException;
/**
* Retrieves the commit message of the change edit.
*
* @return the commit message of the change edit
* @throws RestApiException if the commit message couldn't be retrieved or a change edit wasn't
* present
*/
String getCommitMessage() throws RestApiException;
/**
* Modifies the commit message of the change edit. If the change edit doesn't exist, it will be
* created based on the current patch set of the change.
*
* @param newCommitMessage the desired commit message
* @throws RestApiException if the commit message couldn't be modified
*/
void modifyCommitMessage(String newCommitMessage) throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements ChangeEditApi {
@Override
public Optional<EditInfo> get() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void create() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void delete() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void rebase() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void publish() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void publish(PublishChangeEditInput publishChangeEditInput) throws RestApiException {
throw new NotImplementedException();
}
@Override
public Optional<BinaryResult> getFile(String filePath) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void renameFile(String oldFilePath, String newFilePath) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void restoreFile(String filePath) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void modifyFile(String filePath, RawInput newContent) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void deleteFile(String filePath) throws RestApiException {
throw new NotImplementedException();
}
@Override
public String getCommitMessage() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void modifyCommitMessage(String newCommitMessage) throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,184 @@
// 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.extensions.api.changes;
import com.google.gerrit.extensions.client.ListChangesOption;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.ChangeInput;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
public interface Changes {
/**
* Look up a change by numeric ID.
*
* <p><strong>Note:</strong> This method eagerly reads the change. Methods that mutate the change
* do not necessarily re-read the change. Therefore, calling a getter method on an instance after
* calling a mutation method on that same instance is not guaranteed to reflect the mutation. It
* is not recommended to store references to {@code ChangeApi} instances.
*
* @param id change number.
* @return API for accessing the change.
* @throws RestApiException if an error occurred.
*/
ChangeApi id(int id) throws RestApiException;
/**
* Look up a change by string ID.
*
* @see #id(int)
* @param id any identifier supported by the REST API, including change number, Change-Id, or
* project~branch~Change-Id triplet.
* @return API for accessing the change.
* @throws RestApiException if an error occurred.
*/
ChangeApi id(String id) throws RestApiException;
/**
* Look up a change by project, branch, and change ID.
*
* @see #id(int)
*/
ChangeApi id(String project, String branch, String id) throws RestApiException;
/**
* Look up a change by project and numeric ID.
*
* @param project project name.
* @param id change number.
* @see #id(int)
*/
ChangeApi id(String project, int id) throws RestApiException;
ChangeApi create(ChangeInput in) throws RestApiException;
QueryRequest query();
QueryRequest query(String query);
abstract class QueryRequest {
private String query;
private int limit;
private int start;
private EnumSet<ListChangesOption> options = EnumSet.noneOf(ListChangesOption.class);
public abstract List<ChangeInfo> get() throws RestApiException;
public QueryRequest withQuery(String query) {
this.query = query;
return this;
}
public QueryRequest withLimit(int limit) {
this.limit = limit;
return this;
}
public QueryRequest withStart(int start) {
this.start = start;
return this;
}
public QueryRequest withOption(ListChangesOption options) {
this.options.add(options);
return this;
}
public QueryRequest withOptions(ListChangesOption... options) {
this.options.addAll(Arrays.asList(options));
return this;
}
public QueryRequest withOptions(EnumSet<ListChangesOption> options) {
this.options = options;
return this;
}
public String getQuery() {
return query;
}
public int getLimit() {
return limit;
}
public int getStart() {
return start;
}
public EnumSet<ListChangesOption> getOptions() {
return options;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('{').append(query);
if (limit != 0) {
sb.append(", limit=").append(limit);
}
if (start != 0) {
sb.append(", start=").append(start);
}
if (!options.isEmpty()) {
sb.append("options=").append(options);
}
return sb.append('}').toString();
}
}
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements Changes {
@Override
public ChangeApi id(int id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeApi id(String triplet) throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeApi id(String project, String branch, String id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeApi id(String project, int id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeApi create(ChangeInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public QueryRequest query() {
throw new NotImplementedException();
}
@Override
public QueryRequest query(String query) {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,31 @@
// 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.extensions.api.changes;
import java.util.Map;
public class CherryPickInput {
public String message;
// Cherry-pick destination branch, which will be the destination of the newly created change.
public String destination;
// 40-hex digit SHA-1 of the commit which will be the parent commit of the newly created change.
public String base;
public Integer parent;
public NotifyHandling notify = NotifyHandling.NONE;
public Map<RecipientType, NotifyInfo> notifyDetails;
public boolean keepReviewers;
}

View File

@@ -0,0 +1,50 @@
// Copyright (C) 2014 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.CommentInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
public interface CommentApi {
CommentInfo get() throws RestApiException;
/**
* Deletes a published comment of a revision. For NoteDb, it deletes the comment by rewriting the
* commit history.
*
* <p>Note instead of deleting the whole comment, this endpoint just replaces the comment's
* message.
*
* @return the comment with its message updated.
*/
CommentInfo delete(DeleteCommentInput input) throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements CommentApi {
@Override
public CommentInfo get() throws RestApiException {
throw new NotImplementedException();
}
@Override
public CommentInfo delete(DeleteCommentInput input) throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,30 @@
// Copyright (C) 2017 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.common.base.Strings;
import com.google.gerrit.extensions.restapi.DefaultInput;
public class DeleteCommentInput {
@DefaultInput public String reason;
public DeleteCommentInput() {
reason = "";
}
public DeleteCommentInput(String reason) {
this.reason = Strings.nullToEmpty(reason);
}
}

View File

@@ -0,0 +1,25 @@
// 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 java.util.Map;
/** Input passed to {@code DELETE /changes/[id]/reviewers/[id]}. */
public class DeleteReviewerInput {
/** Who to send email notifications to after the reviewer is deleted. */
public NotifyHandling notify = null;
public Map<RecipientType, NotifyInfo> notifyDetails;
}

View File

@@ -0,0 +1,28 @@
// 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.DefaultInput;
import java.util.Map;
/** Input passed to {@code DELETE /changes/[id]/reviewers/[id]/votes/[label]}. */
public class DeleteVoteInput {
@DefaultInput public String label;
/** Who to send email notifications to after vote is deleted. */
public NotifyHandling notify = NotifyHandling.ALL;
public Map<RecipientType, NotifyInfo> notifyDetails;
}

View File

@@ -0,0 +1,41 @@
// Copyright (C) 2014 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.CommentInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
public interface DraftApi extends CommentApi {
CommentInfo update(DraftInput in) throws RestApiException;
void delete() throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented extends CommentApi.NotImplemented implements DraftApi {
@Override
public CommentInfo update(DraftInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void delete() throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,36 @@
// Copyright (C) 2014 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.client.Comment;
import java.util.Objects;
public class DraftInput extends Comment {
public String tag;
@Override
public boolean equals(Object o) {
if (super.equals(o)) {
DraftInput di = (DraftInput) o;
return Objects.equals(tag, di.tag);
}
return false;
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), tag);
}
}

View File

@@ -0,0 +1,127 @@
// Copyright (C) 2014 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.client.DiffPreferencesInfo.Whitespace;
import com.google.gerrit.extensions.common.DiffInfo;
import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
import java.util.OptionalInt;
public interface FileApi {
BinaryResult content() throws RestApiException;
/** Diff against the revision's parent version of the file. */
DiffInfo diff() throws RestApiException;
/** @param base revision id of the revision to be used as the diff base */
DiffInfo diff(String base) throws RestApiException;
/** @param parent 1-based parent number to diff against */
DiffInfo diff(int parent) throws RestApiException;
/**
* Creates a request to retrieve the diff. On the returned request formatting options for the diff
* can be set.
*/
DiffRequest diffRequest() throws RestApiException;
abstract class DiffRequest {
private String base;
private Integer context;
private Boolean intraline;
private Whitespace whitespace;
private OptionalInt parent = OptionalInt.empty();
public abstract DiffInfo get() throws RestApiException;
public DiffRequest withBase(String base) {
this.base = base;
return this;
}
public DiffRequest withContext(int context) {
this.context = context;
return this;
}
public DiffRequest withIntraline(boolean intraline) {
this.intraline = intraline;
return this;
}
public DiffRequest withWhitespace(Whitespace whitespace) {
this.whitespace = whitespace;
return this;
}
public DiffRequest withParent(int parent) {
this.parent = OptionalInt.of(parent);
return this;
}
public String getBase() {
return base;
}
public Integer getContext() {
return context;
}
public Boolean getIntraline() {
return intraline;
}
public Whitespace getWhitespace() {
return whitespace;
}
public OptionalInt getParent() {
return parent;
}
}
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements FileApi {
@Override
public BinaryResult content() throws RestApiException {
throw new NotImplementedException();
}
@Override
public DiffInfo diff() throws RestApiException {
throw new NotImplementedException();
}
@Override
public DiffInfo diff(String base) throws RestApiException {
throw new NotImplementedException();
}
@Override
public DiffInfo diff(int parent) throws RestApiException {
throw new NotImplementedException();
}
@Override
public DiffRequest diffRequest() throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2014 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;
public class FixInput {
public boolean deletePatchSetIfCommitMissing;
public String expectMergedAs;
}

View File

@@ -0,0 +1,29 @@
// Copyright (C) 2014 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.DefaultInput;
import java.util.Set;
public class HashtagsInput {
@DefaultInput public Set<String> add;
public Set<String> remove;
public HashtagsInput() {}
public HashtagsInput(Set<String> add) {
this.add = add;
}
}

View File

@@ -0,0 +1,31 @@
// Copyright (C) 2017 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 java.util.Collection;
import java.util.List;
import java.util.Map;
public class IncludedInInfo {
public List<String> branches;
public List<String> tags;
public Map<String, Collection<String>> external;
public IncludedInInfo(
List<String> branches, List<String> tags, Map<String, Collection<String>> external) {
this.branches = branches;
this.tags = tags;
this.external = external;
}
}

View File

@@ -0,0 +1,20 @@
// 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;
public class MoveInput {
public String message;
public String destinationBranch;
}

View File

@@ -0,0 +1,22 @@
// 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;
public enum NotifyHandling {
NONE,
OWNER,
OWNER_REVIEWERS,
ALL
}

View File

@@ -0,0 +1,26 @@
// 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 java.util.List;
/** Detailed information about who should be notified about an update. */
public class NotifyInfo {
public List<String> accounts;
public NotifyInfo(List<String> accounts) {
this.accounts = accounts;
}
}

View File

@@ -0,0 +1,25 @@
// 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 java.util.Map;
/** Input passed to {@code POST /changes/[id]/edit:publish/}. */
public class PublishChangeEditInput {
/** Who to send email notifications to after the change edit is published. */
public NotifyHandling notify = NotifyHandling.ALL;
public Map<RecipientType, NotifyInfo> notifyDetails;
}

View File

@@ -0,0 +1,19 @@
// 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;
public class RebaseInput {
public String base;
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2009 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;
public enum RecipientType {
TO,
CC,
BCC
}

View File

@@ -0,0 +1,21 @@
// 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.extensions.api.changes;
import com.google.gerrit.extensions.restapi.DefaultInput;
public class RestoreInput {
@DefaultInput public String message;
}

View File

@@ -0,0 +1,21 @@
// 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.extensions.api.changes;
import com.google.gerrit.extensions.restapi.DefaultInput;
public class RevertInput {
@DefaultInput public String message;
}

View File

@@ -0,0 +1,187 @@
// 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.extensions.api.changes;
import static com.google.gerrit.extensions.client.ReviewerState.REVIEWER;
import com.google.gerrit.extensions.client.Comment;
import com.google.gerrit.extensions.client.ReviewerState;
import com.google.gerrit.extensions.common.FixSuggestionInfo;
import com.google.gerrit.extensions.restapi.DefaultInput;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/** Input passed to {@code POST /changes/[id]/revisions/[id]/review}. */
public class ReviewInput {
@DefaultInput public String message;
public String tag;
public Map<String, Short> labels;
public Map<String, List<CommentInput>> comments;
public Map<String, List<RobotCommentInput>> robotComments;
/**
* If true require all labels to be within the user's permitted ranges based on access controls,
* attempting to use a label not granted to the user will fail the entire modify operation early.
* If false the operation will execute anyway, but the proposed labels given by the user will be
* modified to be the "best" value allowed by the access controls, or ignored if the label does
* not exist.
*/
public boolean strictLabels = true;
/**
* How to process draft comments already in the database that were not also described in this
* input request.
*
* <p>Defaults to DELETE, unless {@link #onBehalfOf} is set, in which case it defaults to KEEP and
* any other value is disallowed.
*/
public DraftHandling drafts;
/** Who to send email notifications to after review is stored. */
public NotifyHandling notify;
public Map<RecipientType, NotifyInfo> notifyDetails;
/** If true check to make sure that the comments being posted aren't already present. */
public boolean omitDuplicateComments;
/**
* Account ID, name, email address or username of another user. The review will be posted/updated
* on behalf of this named user instead of the caller. Caller must have the labelAs-$NAME
* permission granted for each label that appears in {@link #labels}. This is in addition to the
* named user also needing to have permission to use the labels.
*
* <p>{@link #strictLabels} impacts how labels is processed for the named user, not the caller.
*/
public String onBehalfOf;
/** Reviewers that should be added to this change. */
public List<AddReviewerInput> reviewers;
/**
* If true mark the change as work in progress. It is an error for both {@link #workInProgress}
* and {@link #ready} to be true.
*/
public boolean workInProgress;
/**
* If true mark the change as ready for review. It is an error for both {@link #workInProgress}
* and {@link #ready} to be true.
*/
public boolean ready;
public enum DraftHandling {
/** Delete pending drafts on this revision only. */
DELETE,
/** Publish pending drafts on this revision only. */
PUBLISH,
/** Leave pending drafts alone. */
KEEP,
/** Publish pending drafts on all revisions. */
PUBLISH_ALL_REVISIONS
}
public static class CommentInput extends Comment {}
public static class RobotCommentInput extends CommentInput {
public String robotId;
public String robotRunId;
public String url;
public Map<String, String> properties;
public List<FixSuggestionInfo> fixSuggestions;
}
public ReviewInput message(String msg) {
message = msg != null && !msg.isEmpty() ? msg : null;
return this;
}
public ReviewInput label(String name, short value) {
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException();
}
if (labels == null) {
labels = new LinkedHashMap<>(4);
}
labels.put(name, value);
return this;
}
public ReviewInput label(String name, int value) {
if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
throw new IllegalArgumentException();
}
return label(name, (short) value);
}
public ReviewInput label(String name) {
return label(name, (short) 1);
}
public ReviewInput reviewer(String reviewer) {
return reviewer(reviewer, REVIEWER, false);
}
public ReviewInput reviewer(String reviewer, ReviewerState state, boolean confirmed) {
AddReviewerInput input = new AddReviewerInput();
input.reviewer = reviewer;
input.state = state;
input.confirmed = confirmed;
if (reviewers == null) {
reviewers = new ArrayList<>();
}
reviewers.add(input);
return this;
}
public ReviewInput setWorkInProgress(boolean workInProgress) {
this.workInProgress = workInProgress;
ready = !workInProgress;
return this;
}
public ReviewInput setReady(boolean ready) {
this.ready = ready;
workInProgress = !ready;
return this;
}
public static ReviewInput recommend() {
return new ReviewInput().label("Code-Review", 1);
}
public static ReviewInput dislike() {
return new ReviewInput().label("Code-Review", -1);
}
public static ReviewInput noScore() {
return new ReviewInput().label("Code-Review", 0);
}
public static ReviewInput approve() {
return new ReviewInput().label("Code-Review", 2);
}
public static ReviewInput reject() {
return new ReviewInput().label("Code-Review", -2);
}
}

View File

@@ -0,0 +1,41 @@
// 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.common.Nullable;
import java.util.Map;
/** Result object representing the outcome of a review request. */
public class ReviewResult {
/**
* Map of labels to values after the review was posted. Null if any reviewer additions were
* rejected.
*/
@Nullable public Map<String, Short> labels;
/**
* Map of account or group identifier to outcome of adding as a reviewer. Null if no reviewer
* additions were requested.
*/
@Nullable public Map<String, AddReviewerResult> reviewers;
/**
* Boolean indicating whether the change was moved out of WIP by this review. Either true or null.
*/
@Nullable public Boolean ready;
/** Error message for non-200 responses. */
@Nullable public String error;
}

View File

@@ -0,0 +1,63 @@
// Copyright (C) 2014 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;
import java.util.Map;
public interface ReviewerApi {
Map<String, Short> votes() throws RestApiException;
void deleteVote(String label) throws RestApiException;
void deleteVote(DeleteVoteInput input) throws RestApiException;
void remove() throws RestApiException;
void remove(DeleteReviewerInput input) throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements ReviewerApi {
@Override
public Map<String, Short> votes() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void deleteVote(String label) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void deleteVote(DeleteVoteInput input) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void remove() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void remove(DeleteReviewerInput input) throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,45 @@
// 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.common.Nullable;
import com.google.gerrit.extensions.common.AccountInfo;
import java.util.Map;
/** Account and approval details for an added reviewer. */
public class ReviewerInfo extends AccountInfo {
/**
* {@link Map} of label name to initial value for each approval the reviewer is responsible for.
*/
@Nullable public Map<String, String> approvals;
public static ReviewerInfo byEmail(@Nullable String name, String email) {
ReviewerInfo info = new ReviewerInfo();
info.name = name;
info.email = email;
return info;
}
public ReviewerInfo(Integer id) {
super(id);
}
@Override
public String toString() {
return username;
}
private ReviewerInfo() {}
}

View File

@@ -0,0 +1,372 @@
// 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.extensions.api.changes;
import com.google.gerrit.extensions.client.SubmitType;
import com.google.gerrit.extensions.common.ActionInfo;
import com.google.gerrit.extensions.common.CommentInfo;
import com.google.gerrit.extensions.common.CommitInfo;
import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.FileInfo;
import com.google.gerrit.extensions.common.MergeableInfo;
import com.google.gerrit.extensions.common.RobotCommentInfo;
import com.google.gerrit.extensions.common.TestSubmitRuleInput;
import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
import java.util.List;
import java.util.Map;
import java.util.Set;
public interface RevisionApi {
@Deprecated
void delete() throws RestApiException;
String description() throws RestApiException;
void description(String description) throws RestApiException;
ReviewResult review(ReviewInput in) throws RestApiException;
void submit() throws RestApiException;
void submit(SubmitInput in) throws RestApiException;
BinaryResult submitPreview() throws RestApiException;
BinaryResult submitPreview(String format) throws RestApiException;
@Deprecated
void publish() throws RestApiException;
ChangeApi cherryPick(CherryPickInput in) throws RestApiException;
ChangeApi rebase() throws RestApiException;
ChangeApi rebase(RebaseInput in) throws RestApiException;
boolean canRebase() throws RestApiException;
RevisionReviewerApi reviewer(String id) throws RestApiException;
void setReviewed(String path, boolean reviewed) throws RestApiException;
Set<String> reviewed() throws RestApiException;
Map<String, FileInfo> files() throws RestApiException;
Map<String, FileInfo> files(String base) throws RestApiException;
Map<String, FileInfo> files(int parentNum) throws RestApiException;
List<String> queryFiles(String query) throws RestApiException;
FileApi file(String path);
CommitInfo commit(boolean addLinks) throws RestApiException;
MergeableInfo mergeable() throws RestApiException;
MergeableInfo mergeableOtherBranches() throws RestApiException;
Map<String, List<CommentInfo>> comments() throws RestApiException;
Map<String, List<RobotCommentInfo>> robotComments() throws RestApiException;
Map<String, List<CommentInfo>> drafts() throws RestApiException;
List<CommentInfo> commentsAsList() throws RestApiException;
List<CommentInfo> draftsAsList() throws RestApiException;
List<RobotCommentInfo> robotCommentsAsList() throws RestApiException;
/**
* Applies the indicated fix by creating a new change edit or integrating the fix with the
* existing change edit. If no change edit exists before this call, the fix must refer to the
* current patch set. If a change edit exists, the fix must refer to the patch set on which the
* change edit is based.
*
* @param fixId the ID of the fix which should be applied
* @throws RestApiException if the fix couldn't be applied
*/
EditInfo applyFix(String fixId) throws RestApiException;
DraftApi createDraft(DraftInput in) throws RestApiException;
DraftApi draft(String id) throws RestApiException;
CommentApi comment(String id) throws RestApiException;
RobotCommentApi robotComment(String id) throws RestApiException;
String etag() throws RestApiException;
/** Returns patch of revision. */
BinaryResult patch() throws RestApiException;
BinaryResult patch(String path) throws RestApiException;
Map<String, ActionInfo> actions() throws RestApiException;
SubmitType submitType() throws RestApiException;
SubmitType testSubmitType(TestSubmitRuleInput in) throws RestApiException;
MergeListRequest getMergeList() throws RestApiException;
abstract class MergeListRequest {
private boolean addLinks;
private int uninterestingParent = 1;
public abstract List<CommitInfo> get() throws RestApiException;
public MergeListRequest withLinks() {
this.addLinks = true;
return this;
}
public MergeListRequest withUninterestingParent(int uninterestingParent) {
this.uninterestingParent = uninterestingParent;
return this;
}
public boolean getAddLinks() {
return addLinks;
}
public int getUninterestingParent() {
return uninterestingParent;
}
}
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements RevisionApi {
@Deprecated
@Override
public void delete() throws RestApiException {
throw new NotImplementedException();
}
@Override
public ReviewResult review(ReviewInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void submit() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void submit(SubmitInput in) throws RestApiException {
throw new NotImplementedException();
}
@Deprecated
@Override
public void publish() throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeApi cherryPick(CherryPickInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeApi rebase() throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeApi rebase(RebaseInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public boolean canRebase() throws RestApiException {
throw new NotImplementedException();
}
@Override
public RevisionReviewerApi reviewer(String id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void setReviewed(String path, boolean reviewed) throws RestApiException {
throw new NotImplementedException();
}
@Override
public Set<String> reviewed() throws RestApiException {
throw new NotImplementedException();
}
@Override
public MergeableInfo mergeable() throws RestApiException {
throw new NotImplementedException();
}
@Override
public MergeableInfo mergeableOtherBranches() throws RestApiException {
throw new NotImplementedException();
}
@Override
public Map<String, FileInfo> files(String base) throws RestApiException {
throw new NotImplementedException();
}
@Override
public Map<String, FileInfo> files(int parentNum) throws RestApiException {
throw new NotImplementedException();
}
@Override
public Map<String, FileInfo> files() throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<String> queryFiles(String query) throws RestApiException {
throw new NotImplementedException();
}
@Override
public FileApi file(String path) {
throw new NotImplementedException();
}
@Override
public CommitInfo commit(boolean addLinks) throws RestApiException {
throw new NotImplementedException();
}
@Override
public Map<String, List<CommentInfo>> comments() throws RestApiException {
throw new NotImplementedException();
}
@Override
public Map<String, List<RobotCommentInfo>> robotComments() throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<CommentInfo> commentsAsList() throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<CommentInfo> draftsAsList() throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<RobotCommentInfo> robotCommentsAsList() throws RestApiException {
throw new NotImplementedException();
}
@Override
public EditInfo applyFix(String fixId) throws RestApiException {
throw new NotImplementedException();
}
@Override
public Map<String, List<CommentInfo>> drafts() throws RestApiException {
throw new NotImplementedException();
}
@Override
public DraftApi createDraft(DraftInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public DraftApi draft(String id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public CommentApi comment(String id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public RobotCommentApi robotComment(String id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public BinaryResult patch() throws RestApiException {
throw new NotImplementedException();
}
@Override
public BinaryResult patch(String path) throws RestApiException {
throw new NotImplementedException();
}
@Override
public Map<String, ActionInfo> actions() throws RestApiException {
throw new NotImplementedException();
}
@Override
public SubmitType submitType() throws RestApiException {
throw new NotImplementedException();
}
@Override
public BinaryResult submitPreview() throws RestApiException {
throw new NotImplementedException();
}
@Override
public BinaryResult submitPreview(String format) throws RestApiException {
throw new NotImplementedException();
}
@Override
public SubmitType testSubmitType(TestSubmitRuleInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public MergeListRequest getMergeList() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void description(String description) throws RestApiException {
throw new NotImplementedException();
}
@Override
public String description() throws RestApiException {
throw new NotImplementedException();
}
@Override
public String etag() throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,48 @@
// Copyright (C) 2017 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;
import java.util.Map;
public interface RevisionReviewerApi {
Map<String, Short> votes() throws RestApiException;
void deleteVote(String label) throws RestApiException;
void deleteVote(DeleteVoteInput input) throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements RevisionReviewerApi {
@Override
public Map<String, Short> votes() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void deleteVote(String label) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void deleteVote(DeleteVoteInput input) throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,34 @@
// 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.common.RobotCommentInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
public interface RobotCommentApi {
RobotCommentInfo get() throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements RobotCommentApi {
@Override
public RobotCommentInfo get() throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,33 @@
// 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 java.util.Set;
public class StarsInput {
public Set<String> add;
public Set<String> remove;
public StarsInput() {}
public StarsInput(Set<String> add) {
this.add = add;
}
public StarsInput(Set<String> add, Set<String> remove) {
this.add = add;
this.remove = remove;
}
}

View File

@@ -0,0 +1,27 @@
// 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.extensions.api.changes;
import java.util.Map;
public class SubmitInput {
/** Not used anymore, kept for backward compatibility */
@Deprecated public boolean waitForMerge;
public String onBehalfOf;
public NotifyHandling notify = NotifyHandling.ALL;
public Map<RecipientType, NotifyInfo> notifyDetails;
}

View File

@@ -0,0 +1,22 @@
// 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.common.ChangeInfo;
import java.util.List;
public class SubmittedTogetherInfo {
public List<ChangeInfo> changes;
public int nonVisibleChanges;
}

View File

@@ -0,0 +1,20 @@
// 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;
/** Output options available for submitted_together requests. */
public enum SubmittedTogetherOption {
NON_VISIBLE_CHANGES;
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2017 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.DefaultInput;
public class TopicInput {
@DefaultInput public String topic;
}

View File

@@ -0,0 +1,23 @@
// Copyright (C) 2017 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.config;
public class AccessCheckInfo {
public String message;
// HTTP status code
public int status;
// for future extension, we may add inputs / results for bulk checks.
}

View File

@@ -0,0 +1,30 @@
// Copyright (C) 2017 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.config;
import com.google.gerrit.common.Nullable;
public class AccessCheckInput {
public String account;
@Nullable public String ref;
public AccessCheckInput(String account, @Nullable String ref) {
this.account = account;
this.ref = ref;
}
public AccessCheckInput() {}
}

View File

@@ -0,0 +1,33 @@
// 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.config;
import com.google.gerrit.extensions.restapi.NotImplementedException;
public interface Config {
/** @return An API for getting server related configurations. */
Server server();
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements Config {
@Override
public Server server() {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,73 @@
// Copyright (C) 2017 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.config;
import java.util.List;
import java.util.Objects;
public class ConsistencyCheckInfo {
public CheckAccountsResultInfo checkAccountsResult;
public CheckAccountExternalIdsResultInfo checkAccountExternalIdsResult;
public static class CheckAccountsResultInfo {
public List<ConsistencyProblemInfo> problems;
public CheckAccountsResultInfo(List<ConsistencyProblemInfo> problems) {
this.problems = problems;
}
}
public static class CheckAccountExternalIdsResultInfo {
public List<ConsistencyProblemInfo> problems;
public CheckAccountExternalIdsResultInfo(List<ConsistencyProblemInfo> problems) {
this.problems = problems;
}
}
public static class ConsistencyProblemInfo {
public enum Status {
ERROR,
WARNING,
}
public final Status status;
public final String message;
public ConsistencyProblemInfo(Status status, String message) {
this.status = status;
this.message = message;
}
@Override
public boolean equals(Object o) {
if (o instanceof ConsistencyProblemInfo) {
ConsistencyProblemInfo other = ((ConsistencyProblemInfo) o);
return Objects.equals(status, other.status) && Objects.equals(message, other.message);
}
return false;
}
@Override
public int hashCode() {
return Objects.hash(status, message);
}
@Override
public String toString() {
return status.name() + ": " + message;
}
}
}

View File

@@ -0,0 +1,24 @@
// Copyright (C) 2017 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.config;
public class ConsistencyCheckInput {
public CheckAccountsInput checkAccounts;
public CheckAccountExternalIdsInput checkAccountExternalIds;
public static class CheckAccountsInput {}
public static class CheckAccountExternalIdsInput {}
}

View File

@@ -0,0 +1,81 @@
// 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.config;
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
import com.google.gerrit.extensions.common.ServerInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
public interface Server {
/** @return Version of server. */
String getVersion() throws RestApiException;
ServerInfo getInfo() throws RestApiException;
GeneralPreferencesInfo getDefaultPreferences() throws RestApiException;
GeneralPreferencesInfo setDefaultPreferences(GeneralPreferencesInfo in) throws RestApiException;
DiffPreferencesInfo getDefaultDiffPreferences() throws RestApiException;
DiffPreferencesInfo setDefaultDiffPreferences(DiffPreferencesInfo in) throws RestApiException;
ConsistencyCheckInfo checkConsistency(ConsistencyCheckInput in) throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements Server {
@Override
public String getVersion() throws RestApiException {
throw new NotImplementedException();
}
@Override
public ServerInfo getInfo() throws RestApiException {
throw new NotImplementedException();
}
@Override
public GeneralPreferencesInfo getDefaultPreferences() throws RestApiException {
throw new NotImplementedException();
}
@Override
public GeneralPreferencesInfo setDefaultPreferences(GeneralPreferencesInfo in)
throws RestApiException {
throw new NotImplementedException();
}
@Override
public DiffPreferencesInfo getDefaultDiffPreferences() throws RestApiException {
throw new NotImplementedException();
}
@Override
public DiffPreferencesInfo setDefaultDiffPreferences(DiffPreferencesInfo in)
throws RestApiException {
throw new NotImplementedException();
}
@Override
public ConsistencyCheckInfo checkConsistency(ConsistencyCheckInput in) throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,252 @@
// 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.groups;
import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.extensions.common.GroupAuditEventInfo;
import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.common.GroupOptionsInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
import java.util.List;
public interface GroupApi {
/** @return group info with no {@code ListGroupsOption}s set. */
GroupInfo get() throws RestApiException;
/** @return group info with all {@code ListGroupsOption}s set. */
GroupInfo detail() throws RestApiException;
/** @return group name. */
String name() throws RestApiException;
/**
* Set group name.
*
* @param name new name.
* @throws RestApiException
*/
void name(String name) throws RestApiException;
/** @return owning group info. */
GroupInfo owner() throws RestApiException;
/**
* Set group owner.
*
* @param owner identifier of new group owner.
* @throws RestApiException
*/
void owner(String owner) throws RestApiException;
/** @return group description. */
String description() throws RestApiException;
/**
* Set group decsription.
*
* @param description new description.
* @throws RestApiException
*/
void description(String description) throws RestApiException;
/** @return group options. */
GroupOptionsInfo options() throws RestApiException;
/**
* Set group options.
*
* @param options new options.
* @throws RestApiException
*/
void options(GroupOptionsInfo options) throws RestApiException;
/**
* List group members, non-recursively.
*
* @return group members.
* @throws RestApiException
*/
List<AccountInfo> members() throws RestApiException;
/**
* List group members.
*
* @param recursive whether to recursively included groups.
* @return group members.
* @throws RestApiException
*/
List<AccountInfo> members(boolean recursive) throws RestApiException;
/**
* Add members to a group.
*
* @param members list of member identifiers, in any format accepted by {@link
* com.google.gerrit.extensions.api.accounts.Accounts#id(String)}
* @throws RestApiException
*/
void addMembers(String... members) throws RestApiException;
/**
* Remove members from a group.
*
* @param members list of member identifiers, in any format accepted by {@link
* com.google.gerrit.extensions.api.accounts.Accounts#id(String)}
* @throws RestApiException
*/
void removeMembers(String... members) throws RestApiException;
/**
* Lists the subgroups of this group.
*
* @return the found subgroups
* @throws RestApiException
*/
List<GroupInfo> includedGroups() throws RestApiException;
/**
* Adds subgroups to this group.
*
* @param groups list of group identifiers, in any format accepted by {@link Groups#id(String)}
* @throws RestApiException
*/
void addGroups(String... groups) throws RestApiException;
/**
* Removes subgroups from this group.
*
* @param groups list of group identifiers, in any format accepted by {@link Groups#id(String)}
* @throws RestApiException
*/
void removeGroups(String... groups) throws RestApiException;
/**
* Returns the audit log of the group.
*
* @return list of audit events of the group.
* @throws RestApiException
*/
List<? extends GroupAuditEventInfo> auditLog() throws RestApiException;
/**
* Reindexes the group.
*
* <p>Only supported for internal groups.
*
* @throws RestApiException
*/
void index() throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements GroupApi {
@Override
public GroupInfo get() throws RestApiException {
throw new NotImplementedException();
}
@Override
public GroupInfo detail() throws RestApiException {
throw new NotImplementedException();
}
@Override
public String name() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void name(String name) throws RestApiException {
throw new NotImplementedException();
}
@Override
public GroupInfo owner() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void owner(String owner) throws RestApiException {
throw new NotImplementedException();
}
@Override
public String description() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void description(String description) throws RestApiException {
throw new NotImplementedException();
}
@Override
public GroupOptionsInfo options() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void options(GroupOptionsInfo options) throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<AccountInfo> members() throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<AccountInfo> members(boolean recursive) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void addMembers(String... members) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void removeMembers(String... members) throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<GroupInfo> includedGroups() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void addGroups(String... groups) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void removeGroups(String... groups) throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<? extends GroupAuditEventInfo> auditLog() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void index() throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -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.groups;
import java.util.List;
public class GroupInput {
public String name;
public String description;
public Boolean visibleToAll;
public String ownerId;
public List<String> members;
}

View File

@@ -0,0 +1,323 @@
// 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.groups;
import com.google.gerrit.extensions.client.ListGroupsOption;
import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
public interface Groups {
/**
* Look up a group by ID.
*
* <p><strong>Note:</strong> This method eagerly reads the group. Methods that mutate the group do
* not necessarily re-read the group. Therefore, calling a getter method on an instance after
* calling a mutation method on that same instance is not guaranteed to reflect the mutation. It
* is not recommended to store references to {@code groupApi} instances.
*
* @param id any identifier supported by the REST API, including group name or UUID.
* @return API for accessing the group.
* @throws RestApiException if an error occurred.
*/
GroupApi id(String id) throws RestApiException;
/** Create a new group with the given name and default options. */
GroupApi create(String name) throws RestApiException;
/** Create a new group. */
GroupApi create(GroupInput input) throws RestApiException;
/** @return new request for listing groups. */
ListRequest list();
/**
* Query groups.
*
* <p>Example code: {@code query().withQuery("inname:test").withLimit(10).get()}
*
* @return API for setting parameters and getting result.
*/
QueryRequest query();
/**
* Query groups.
*
* <p>Shortcut API for {@code query().withQuery(String)}.
*
* @see #query()
*/
QueryRequest query(String query);
abstract class ListRequest {
private final EnumSet<ListGroupsOption> options = EnumSet.noneOf(ListGroupsOption.class);
private final List<String> projects = new ArrayList<>();
private final List<String> groups = new ArrayList<>();
private boolean visibleToAll;
private String user;
private boolean owned;
private int limit;
private int start;
private String substring;
private String suggest;
private String regex;
private String ownedBy;
public List<GroupInfo> get() throws RestApiException {
Map<String, GroupInfo> map = getAsMap();
List<GroupInfo> result = new ArrayList<>(map.size());
for (Map.Entry<String, GroupInfo> e : map.entrySet()) {
// ListGroups "helpfully" nulls out names when converting to a map.
e.getValue().name = e.getKey();
result.add(e.getValue());
}
return Collections.unmodifiableList(result);
}
public abstract Map<String, GroupInfo> getAsMap() throws RestApiException;
public ListRequest addOption(ListGroupsOption option) {
options.add(option);
return this;
}
public ListRequest addOptions(ListGroupsOption... options) {
return addOptions(Arrays.asList(options));
}
public ListRequest addOptions(Iterable<ListGroupsOption> options) {
for (ListGroupsOption option : options) {
this.options.add(option);
}
return this;
}
public ListRequest withProject(String project) {
projects.add(project);
return this;
}
public ListRequest addGroup(String uuid) {
groups.add(uuid);
return this;
}
public ListRequest withVisibleToAll(boolean visible) {
visibleToAll = visible;
return this;
}
public ListRequest withUser(String user) {
this.user = user;
return this;
}
public ListRequest withOwned(boolean owned) {
this.owned = owned;
return this;
}
public ListRequest withLimit(int limit) {
this.limit = limit;
return this;
}
public ListRequest withStart(int start) {
this.start = start;
return this;
}
public ListRequest withSubstring(String substring) {
this.substring = substring;
return this;
}
public ListRequest withRegex(String regex) {
this.regex = regex;
return this;
}
public ListRequest withSuggest(String suggest) {
this.suggest = suggest;
return this;
}
public ListRequest withOwnedBy(String ownedBy) {
this.ownedBy = ownedBy;
return this;
}
public EnumSet<ListGroupsOption> getOptions() {
return options;
}
public List<String> getProjects() {
return Collections.unmodifiableList(projects);
}
public List<String> getGroups() {
return Collections.unmodifiableList(groups);
}
public boolean getVisibleToAll() {
return visibleToAll;
}
public String getUser() {
return user;
}
public boolean getOwned() {
return owned;
}
public int getLimit() {
return limit;
}
public int getStart() {
return start;
}
public String getSubstring() {
return substring;
}
public String getRegex() {
return regex;
}
public String getSuggest() {
return suggest;
}
public String getOwnedBy() {
return ownedBy;
}
}
/**
* API for setting parameters and getting result. Used for {@code query()}.
*
* @see #query()
*/
abstract class QueryRequest {
private String query;
private int limit;
private int start;
private EnumSet<ListGroupsOption> options = EnumSet.noneOf(ListGroupsOption.class);
/** Execute query and returns the matched groups as list. */
public abstract List<GroupInfo> get() throws RestApiException;
/**
* Set query.
*
* @param query needs to be in human-readable form.
*/
public QueryRequest withQuery(String query) {
this.query = query;
return this;
}
/**
* Set limit for returned list of groups. Optional; server-default is used when not provided.
*/
public QueryRequest withLimit(int limit) {
this.limit = limit;
return this;
}
/** Set number of groups to skip. Optional; no groups are skipped when not provided. */
public QueryRequest withStart(int start) {
this.start = start;
return this;
}
public QueryRequest withOption(ListGroupsOption options) {
this.options.add(options);
return this;
}
public QueryRequest withOptions(ListGroupsOption... options) {
this.options.addAll(Arrays.asList(options));
return this;
}
public QueryRequest withOptions(EnumSet<ListGroupsOption> options) {
this.options = options;
return this;
}
public String getQuery() {
return query;
}
public int getLimit() {
return limit;
}
public int getStart() {
return start;
}
public EnumSet<ListGroupsOption> getOptions() {
return options;
}
}
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements Groups {
@Override
public GroupApi id(String id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public GroupApi create(String name) throws RestApiException {
throw new NotImplementedException();
}
@Override
public GroupApi create(GroupInput input) throws RestApiException {
throw new NotImplementedException();
}
@Override
public ListRequest list() {
throw new NotImplementedException();
}
@Override
public QueryRequest query() {
throw new NotImplementedException();
}
@Override
public QueryRequest query(String query) {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2017 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.groups;
import com.google.gerrit.extensions.restapi.DefaultInput;
public class OwnerInput {
@DefaultInput public String owner;
}

View File

@@ -0,0 +1,36 @@
// Copyright (C) 2017 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.lfs;
import com.google.common.base.Joiner;
public final class LfsDefinitions {
public static final String CONTENTTYPE_VND_GIT_LFS_JSON =
"application/vnd.git-lfs+json; charset=utf-8";
public static final String LFS_OBJECTS_PATH = "objects/batch";
public static final String LFS_LOCKS_PATH_REGEX = "locks(?:/(.*)(?:/unlock))?";
public static final String LFS_VERIFICATION_PATH = "locks/verify";
public static final String LFS_UNIFIED_PATHS_REGEX =
Joiner.on('|').join(LFS_OBJECTS_PATH, LFS_LOCKS_PATH_REGEX, LFS_VERIFICATION_PATH);
public static final String LFS_URL_WO_AUTH_REGEX_TEAMPLATE = "(?:/p/|/)(.+)(?:/info/lfs/)(?:%s)$";
public static final String LFS_URL_WO_AUTH_REGEX =
String.format(LFS_URL_WO_AUTH_REGEX_TEAMPLATE, LFS_UNIFIED_PATHS_REGEX);
public static final String LFS_URL_REGEX_TEMPLATE = "^(?:/a)?" + LFS_URL_WO_AUTH_REGEX_TEAMPLATE;
public static final String LFS_URL_REGEX =
String.format(LFS_URL_REGEX_TEMPLATE, LFS_UNIFIED_PATHS_REGEX);
private LfsDefinitions() {}
}

View File

@@ -0,0 +1,55 @@
// Copyright (C) 2017 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.plugins;
import com.google.gerrit.extensions.common.PluginInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
public interface PluginApi {
PluginInfo get() throws RestApiException;
void enable() throws RestApiException;
void disable() throws RestApiException;
void reload() throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements PluginApi {
@Override
public PluginInfo get() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void enable() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void disable() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void reload() throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,128 @@
// Copyright (C) 2017 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.plugins;
import com.google.gerrit.extensions.common.InstallPluginInput;
import com.google.gerrit.extensions.common.PluginInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
public interface Plugins {
ListRequest list() throws RestApiException;
PluginApi name(String name) throws RestApiException;
PluginApi install(String name, InstallPluginInput input) throws RestApiException;
abstract class ListRequest {
private boolean all;
private int limit;
private int start;
private String substring;
private String prefix;
private String regex;
public List<PluginInfo> get() throws RestApiException {
Map<String, PluginInfo> map = getAsMap();
List<PluginInfo> result = new ArrayList<>(map.size());
for (Map.Entry<String, PluginInfo> e : map.entrySet()) {
result.add(e.getValue());
}
return result;
}
public abstract SortedMap<String, PluginInfo> getAsMap() throws RestApiException;
public ListRequest all() {
this.all = true;
return this;
}
public boolean getAll() {
return all;
}
public ListRequest limit(int limit) {
this.limit = limit;
return this;
}
public int getLimit() {
return limit;
}
public ListRequest start(int start) {
this.start = start;
return this;
}
public int getStart() {
return start;
}
public ListRequest substring(String substring) {
this.substring = substring;
return this;
}
public String getSubstring() {
return substring;
}
public ListRequest prefix(String prefix) {
this.prefix = prefix;
return this;
}
public String getPrefix() {
return prefix;
}
public ListRequest regex(String regex) {
this.regex = regex;
return this;
}
public String getRegex() {
return regex;
}
}
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements Plugins {
@Override
public ListRequest list() {
throw new NotImplementedException();
}
@Override
public PluginApi name(String name) {
throw new NotImplementedException();
}
@Override
public PluginApi install(String name, InstallPluginInput input) throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,33 @@
// Copyright (C) 2017 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.projects;
import com.google.common.collect.Lists;
import java.util.List;
public class BanCommitInput {
public List<String> commits;
public String reason;
public static BanCommitInput fromCommits(String firstCommit, String... moreCommits) {
return fromCommits(Lists.asList(firstCommit, moreCommits));
}
public static BanCommitInput fromCommits(List<String> commits) {
BanCommitInput in = new BanCommitInput();
in.commits = commits;
return in;
}
}

View File

@@ -0,0 +1,64 @@
// 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.extensions.api.projects;
import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
import java.util.List;
public interface BranchApi {
BranchApi create(BranchInput in) throws RestApiException;
BranchInfo get() throws RestApiException;
void delete() throws RestApiException;
/** Returns the content of a file from the HEAD revision. */
BinaryResult file(String path) throws RestApiException;
List<ReflogEntryInfo> reflog() throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements BranchApi {
@Override
public BranchApi create(BranchInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
public BranchInfo get() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void delete() throws RestApiException {
throw new NotImplementedException();
}
@Override
public BinaryResult file(String path) throws RestApiException {
throw new NotImplementedException();
}
@Override
public List<ReflogEntryInfo> reflog() throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -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.projects;
import com.google.gerrit.extensions.common.ActionInfo;
import com.google.gerrit.extensions.common.WebLinkInfo;
import java.util.List;
import java.util.Map;
public class BranchInfo extends RefInfo {
public Map<String, ActionInfo> actions;
public List<WebLinkInfo> webLinks;
}

View File

@@ -0,0 +1,22 @@
// 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.extensions.api.projects;
import com.google.gerrit.extensions.restapi.DefaultInput;
public class BranchInput {
@DefaultInput public String revision;
public String ref;
}

View File

@@ -0,0 +1,41 @@
// 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.projects;
import com.google.gerrit.extensions.common.ProjectInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
public interface ChildProjectApi {
ProjectInfo get() throws RestApiException;
ProjectInfo get(boolean recursive) throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements ChildProjectApi {
@Override
public ProjectInfo get() throws RestApiException {
throw new NotImplementedException();
}
@Override
public ProjectInfo get(boolean recursive) throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,24 @@
// 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.projects;
public class CommentLinkInfo {
public String match;
public String link;
public String html;
public Boolean enabled; // null means true
public transient String name;
}

View File

@@ -0,0 +1,33 @@
// Copyright (C) 2017 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.projects;
import com.google.gerrit.extensions.api.changes.ChangeApi;
import com.google.gerrit.extensions.api.changes.CherryPickInput;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
public interface CommitApi {
ChangeApi cherryPick(CherryPickInput input) throws RestApiException;
/** A default implementation for source compatibility when adding new methods to the interface. */
class NotImplemented implements CommitApi {
@Override
public ChangeApi cherryPick(CherryPickInput input) throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,73 @@
// 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.projects;
import com.google.gerrit.extensions.client.InheritableBoolean;
import com.google.gerrit.extensions.client.ProjectState;
import com.google.gerrit.extensions.client.SubmitType;
import com.google.gerrit.extensions.common.ActionInfo;
import java.util.List;
import java.util.Map;
public class ConfigInfo {
public String description;
public InheritedBooleanInfo useContributorAgreements;
public InheritedBooleanInfo useContentMerge;
public InheritedBooleanInfo useSignedOffBy;
public InheritedBooleanInfo createNewChangeForAllNotInTarget;
public InheritedBooleanInfo requireChangeId;
public InheritedBooleanInfo enableSignedPush;
public InheritedBooleanInfo requireSignedPush;
public InheritedBooleanInfo rejectImplicitMerges;
public InheritedBooleanInfo privateByDefault;
public InheritedBooleanInfo enableReviewerByEmail;
public InheritedBooleanInfo matchAuthorToCommitterDate;
public MaxObjectSizeLimitInfo maxObjectSizeLimit;
public SubmitType submitType;
public ProjectState state;
public Map<String, Map<String, ConfigParameterInfo>> pluginConfig;
public Map<String, ActionInfo> actions;
public Map<String, CommentLinkInfo> commentlinks;
public ThemeInfo theme;
public Map<String, List<String>> extensionPanelNames;
public static class InheritedBooleanInfo {
public Boolean value;
public InheritableBoolean configuredValue;
public Boolean inheritedValue;
}
public static class MaxObjectSizeLimitInfo {
public String value;
public String configuredValue;
public String inheritedValue;
}
public static class ConfigParameterInfo {
public String displayName;
public String description;
public String warning;
public ProjectConfigEntryType type;
public String value;
public Boolean editable;
public Boolean inheritable;
public String configuredValue;
public String inheritedValue;
public List<String> permittedValues;
public List<String> values;
}
}

View File

@@ -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.projects;
import com.google.gerrit.extensions.client.InheritableBoolean;
import com.google.gerrit.extensions.client.ProjectState;
import com.google.gerrit.extensions.client.SubmitType;
import java.util.Map;
public class ConfigInput {
public String description;
public InheritableBoolean useContributorAgreements;
public InheritableBoolean useContentMerge;
public InheritableBoolean useSignedOffBy;
public InheritableBoolean createNewChangeForAllNotInTarget;
public InheritableBoolean requireChangeId;
public InheritableBoolean enableSignedPush;
public InheritableBoolean requireSignedPush;
public InheritableBoolean rejectImplicitMerges;
public InheritableBoolean privateByDefault;
public InheritableBoolean enableReviewerByEmail;
public InheritableBoolean matchAuthorToCommitterDate;
public String maxObjectSizeLimit;
public SubmitType submitType;
public ProjectState state;
public Map<String, Map<String, ConfigValue>> pluginConfigValues;
}

View File

@@ -0,0 +1,22 @@
// 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.projects;
import java.util.List;
public class ConfigValue {
public String value;
public List<String> values;
}

View File

@@ -0,0 +1,48 @@
// Copyright (C) 2017 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.projects;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
public interface DashboardApi {
DashboardInfo get() throws RestApiException;
DashboardInfo get(boolean inherited) throws RestApiException;
void setDefault() throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
*/
class NotImplemented implements DashboardApi {
@Override
public DashboardInfo get() throws RestApiException {
throw new NotImplementedException();
}
@Override
public DashboardInfo get(boolean inherited) throws RestApiException {
throw new NotImplementedException();
}
@Override
public void setDefault() throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,36 @@
// Copyright (C) 2017 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.projects;
import java.util.ArrayList;
import java.util.List;
public class DashboardInfo {
public String id;
public String project;
public String definingProject;
public String ref;
public String path;
public String description;
public String foreach;
public String url;
public Boolean isDefault;
public String title;
public List<DashboardSectionInfo> sections = new ArrayList<>();
public DashboardInfo() {}
}

View File

@@ -0,0 +1,20 @@
// Copyright (C) 2017 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.projects;
public class DashboardSectionInfo {
public String name;
public String query;
}

View File

@@ -0,0 +1,21 @@
// 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.projects;
import java.util.List;
public class DeleteBranchesInput {
public List<String> branches;
}

View File

@@ -0,0 +1,21 @@
// 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.projects;
import java.util.List;
public class DeleteTagsInput {
public List<String> tags;
}

View File

@@ -0,0 +1,19 @@
// 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.projects;
public class DescriptionInput extends com.google.gerrit.extensions.common.DescriptionInput {
public String commitMessage;
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2017 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.projects;
import com.google.gerrit.extensions.restapi.DefaultInput;
public class HeadInput {
@DefaultInput public String ref;
}

Some files were not shown because too many files have changed in this diff Show More