Implement empty REST endpoint for importing projects
The new REST endpoint is available at:
POST /config/server/importer~project
Change-Id: I3f051f20190ea4fb957ab820c65bce095e7e4000
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/Module.java b/src/main/java/com/googlesource/gerrit/plugins/importer/Module.java
index 1b4be2f..48b00d4 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/Module.java
@@ -14,11 +14,19 @@
package com.googlesource.gerrit.plugins.importer;
+import static com.google.gerrit.server.config.ConfigResource.CONFIG_KIND;
+
+import com.google.gerrit.extensions.restapi.RestApiModule;
import com.google.inject.AbstractModule;
class Module extends AbstractModule {
@Override
protected void configure() {
- // TODO
+ install(new RestApiModule() {
+ @Override
+ protected void configure() {
+ post(CONFIG_KIND, "project").to(ProjectRestEndpoint.class);
+ }
+ });
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ProjectRestEndpoint.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ProjectRestEndpoint.java
new file mode 100644
index 0000000..d699c6e
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ProjectRestEndpoint.java
@@ -0,0 +1,38 @@
+//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.googlesource.gerrit.plugins.importer;
+
+import com.google.gerrit.extensions.restapi.RestModifyView;
+import com.google.gerrit.server.config.ConfigResource;
+import com.google.inject.Singleton;
+
+import com.googlesource.gerrit.plugins.importer.ProjectRestEndpoint.Input;
+
+import java.util.List;
+
+@Singleton
+class ProjectRestEndpoint implements RestModifyView<ConfigResource, Input> {
+ public static class Input {
+ public String from;
+ public String user;
+ public String pass;
+ public List<String> projects;
+ }
+
+ @Override
+ public String apply(ConfigResource rsrc, Input input) {
+ return "TODO";
+ }
+}
diff --git a/src/main/resources/Documentation/rest-api-config.md b/src/main/resources/Documentation/rest-api-config.md
new file mode 100644
index 0000000..e7df0ff
--- /dev/null
+++ b/src/main/resources/Documentation/rest-api-config.md
@@ -0,0 +1,61 @@
+@PLUGIN@ - /config/ REST API
+============================
+
+This page describes the REST endpoints that are added by the @PLUGIN@
+plugin.
+
+Please also take note of the general information on the
+[REST API](../../../Documentation/rest-api.html).
+
+<a id="importer-endpoints"> Importer Endpoints
+---------------------------------------------
+
+### <a id="import-project"> Import Project
+_POST /config/server/@PLUGIN@~project_
+
+Imports a project.
+
+The information about which project should be imported must be provided
+in the request body as a [ProjectInput](#project-input) entity.
+
+#### Request
+
+```
+ POST /config/server/@PLUGIN@~project HTTP/1.0
+ Content-Type: application/json;charset=UTF-8
+
+ {
+ "from": "https://some-gerrit-server:8080",
+ "user": "myUser",
+ "pass": "myPassword",
+ "projects": [
+ "myProject",
+ "myOtherProject"
+ ]
+ }
+```
+
+
+<a id="json-entities">JSON Entities
+-----------------------------------
+
+### <a id="project-input"></a>ProjectInput
+
+The `ProjectInput` entity contains information about projects that
+should be imported.
+
+* _from_: URL of the remote system from where the project should be
+imported.
+* _user_: User on remote system.
+* _pass_: Password of remote user.
+* _projects_: The names of the projects to be imported as a list.
+
+
+SEE ALSO
+--------
+
+* [Config related REST endpoints](../../../Documentation/rest-api-config.html)
+
+GERRIT
+------
+Part of [Gerrit Code Review](../../../Documentation/index.html)