You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2018/03/06 23:24:26 UTC
[geode] branch develop updated: GEODE-4787: Re-instate Management
REST API endpoints for 'create index' and 'create region'. (#1563)
This is an automated email from the ASF dual-hosted git repository.
jensdeppe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new eb8f840 GEODE-4787: Re-instate Management REST API endpoints for 'create index' and 'create region'. (#1563)
eb8f840 is described below
commit eb8f840a011f0236a94e8d5575d7401cdd654bc2
Author: John Blum <jb...@pivotal.io>
AuthorDate: Tue Mar 6 15:24:23 2018 -0800
GEODE-4787: Re-instate Management REST API endpoints for 'create index' and 'create region'. (#1563)
Resolves PR #1563.
---
.../web/controllers/ShellCommandsController.java | 47 ++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
index e25ea7d..a48f57a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
@@ -20,6 +20,7 @@ import static org.apache.geode.management.internal.web.util.UriUtils.decode;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Path;
+import java.util.Optional;
import java.util.Set;
import javax.management.AttributeNotFoundException;
@@ -45,11 +46,14 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
+import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.internal.GemFireVersion;
import org.apache.geode.internal.util.IOUtils;
import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.result.CommandResult;
import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
import org.apache.geode.management.internal.web.domain.QueryParameterSource;
/**
@@ -67,6 +71,11 @@ import org.apache.geode.management.internal.web.domain.QueryParameterSource;
@RequestMapping(AbstractCommandsController.REST_API_VERSION)
@SuppressWarnings("unused")
public class ShellCommandsController extends AbstractCommandsController {
+
+ private static final MultipartFile[] DEFAULT_MULTIPART_FILE = null;
+
+ private static final String DEFAULT_INDEX_TYPE = "range";
+
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "/management/commands")
public ResponseEntity<InputStreamResource> command(@RequestParam(value = "cmd") String command,
@RequestParam(value = "resources", required = false) MultipartFile[] fileResource)
@@ -75,6 +84,44 @@ public class ShellCommandsController extends AbstractCommandsController {
return getResponse(result);
}
+ @RequestMapping(method = RequestMethod.POST, value = "/indexes")
+ public ResponseEntity<?> createIndex(@RequestParam(CliStrings.CREATE_INDEX__NAME) String name,
+ @RequestParam(CliStrings.CREATE_INDEX__EXPRESSION) String expression,
+ @RequestParam(CliStrings.CREATE_INDEX__REGION) String region,
+ @RequestParam(value = CliStrings.CREATE_INDEX__TYPE,
+ defaultValue = DEFAULT_INDEX_TYPE) String type)
+ throws IOException {
+
+ CommandStringBuilder command = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+
+ command.addOption(CliStrings.CREATE_INDEX__NAME, name);
+ command.addOption(CliStrings.CREATE_INDEX__EXPRESSION, expression);
+ command.addOption(CliStrings.CREATE_INDEX__REGION, region);
+ command.addOption(CliStrings.CREATE_INDEX__TYPE, type);
+
+ return command(command.toString(), DEFAULT_MULTIPART_FILE);
+ }
+
+ @RequestMapping(method = RequestMethod.POST, value = "/regions")
+ public ResponseEntity<?> createRegion(
+ @RequestParam(CliStrings.CREATE_REGION__REGION) String namePath,
+ @RequestParam(value = CliStrings.CREATE_REGION__SKIPIFEXISTS,
+ defaultValue = "false") Boolean skipIfExists,
+ @RequestParam(value = CliStrings.CREATE_REGION__REGIONSHORTCUT,
+ defaultValue = "PARTITION") RegionShortcut type)
+ throws IOException {
+
+ CommandStringBuilder command = new CommandStringBuilder(CliStrings.CREATE_REGION);
+
+ command.addOption(CliStrings.CREATE_REGION__REGION, namePath);
+ command.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, type.name());
+
+ Optional.ofNullable(skipIfExists)
+ .ifPresent(it -> command.addOption(CliStrings.CREATE_REGION__SKIPIFEXISTS, it.toString()));
+
+ return command(command.toString(), DEFAULT_MULTIPART_FILE);
+ }
+
@RequestMapping(method = RequestMethod.GET, value = "/mbean/attribute")
public ResponseEntity<?> getAttribute(@RequestParam("resourceName") final String resourceName,
@RequestParam("attributeName") final String attributeName)
--
To stop receiving notification emails like this one, please contact
jensdeppe@apache.org.