geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kh...@apache.org
Subject [geode] branch release/1.5.0 updated: GEODE-4787: Re-instate Management REST API endpoints for 'create index' and 'create region'. (#1563) (#1688)
Date Tue, 27 Mar 2018 18:32:42 GMT
This is an automated email from the ASF dual-hosted git repository.

khowe pushed a commit to branch release/1.5.0
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/release/1.5.0 by this push:
     new 4136c95  GEODE-4787: Re-instate Management REST API endpoints for 'create index'
and 'create region'. (#1563) (#1688)
4136c95 is described below

commit 4136c95212b8f8f8854a19b0aa0e340e4610d1ac
Author: Kenneth Howe <khowe@pivotal.io>
AuthorDate: Tue Mar 27 11:32:38 2018 -0700

    GEODE-4787: Re-instate Management REST API endpoints for 'create index' and 'create region'.
(#1563) (#1688)
    
    Cherry-pick from develop
---
 .../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
khowe@apache.org.

Mime
View raw message