diff --git a/adapter-cqld4/pom.xml b/adapter-cqld4/pom.xml index eb4a2027a..d172b5d23 100644 --- a/adapter-cqld4/pom.xml +++ b/adapter-cqld4/pom.xml @@ -44,48 +44,51 @@ org.codehaus.groovy groovy - 3.0.17 org.apache.tinkerpop gremlin-core - 3.6.4 + + + org.apache.commons + commons-collections4 + + org.apache.tinkerpop tinkergraph-gremlin - 3.6.4 com.datastax.oss java-driver-core - 4.16.0 + + + + com.github.docker-java + docker-java-core com.datastax.oss java-driver-query-builder - 4.16.0 org.snakeyaml snakeyaml-engine - 2.6 org.xerial.snappy snappy-java - 1.1.10.1 com.esri.geometry esri-geometry-api - 2.2.4 diff --git a/adapters-api/src/main/java/io/nosqlbench/engine/api/templating/StrInterpolator.java b/adapters-api/src/main/java/io/nosqlbench/engine/api/templating/StrInterpolator.java index a4b8b6773..66d12d058 100644 --- a/adapters-api/src/main/java/io/nosqlbench/engine/api/templating/StrInterpolator.java +++ b/adapters-api/src/main/java/io/nosqlbench/engine/api/templating/StrInterpolator.java @@ -27,6 +27,7 @@ import java.util.function.Function; public class StrInterpolator implements Function { private final static Logger logger = LogManager.getLogger(StrInterpolator.class); + private final MultiMap multimap = new MultiMap(); private final StringSubstitutor substitutor = new StringSubstitutor(multimap, "<<", ">>", '\\') @@ -57,11 +58,6 @@ public class StrInterpolator implements Function { @Override public String apply(String raw) { - if (raw.contains("<<")) { - logger.warn("Deprecated use of '<<...>>' detected as template variable, use TEMPLATE(...) form. '<<...>>' " + - "are reserved in YAML spec for anchors and aliases."); - } - String after = substitutor.replace(substitutor2.replace(raw)); while (!after.equals(raw)) { raw = after; @@ -70,7 +66,7 @@ public class StrInterpolator implements Function { return after; } - public Map checkpointAccesses() { + public Map checkpointAccesses() { return multimap.checkpointAccesses(); } @@ -84,8 +80,8 @@ public class StrInterpolator implements Function { private final List> maps = new ArrayList<>(); private final String warnPrefix = "UNSET"; - private final Map accesses = new LinkedHashMap<>(); - private final Map extractedDefaults = new LinkedHashMap<>(); + private final Map accesses = new LinkedHashMap<>(); + private final Map extractedDefaults = new LinkedHashMap<>(); public void add(Map addedMap) { maps.add(addedMap); @@ -100,7 +96,7 @@ public class StrInterpolator implements Function { key = parts[0]; value = parts[1]; if (!extractedDefaults.containsKey(key)) { - extractedDefaults.put(key, value); + extractedDefaults.put(key,value); } } @@ -111,7 +107,7 @@ public class StrInterpolator implements Function { break; } } - value = (value == null ? extractedDefaults.get(key) : value); + value = (value==null? extractedDefaults.get(key) : value); value = (value != null) ? value : warnPrefix + ":" + key; @@ -120,14 +116,14 @@ public class StrInterpolator implements Function { // " Template variables must resolve to a single value."); // } - accesses.put(key, value); + accesses.put(key,value); logger.debug("Template parameter '" + key + "' applied as '" + value + "'"); return value; } - public Map checkpointAccesses() { - LinkedHashMap accesses = new LinkedHashMap<>(this.accesses); + public Map checkpointAccesses() { + LinkedHashMap accesses = new LinkedHashMap<>(this.accesses); logger.debug("removed template params after applying:" + accesses); this.accesses.clear(); return accesses; diff --git a/engine-api/pom.xml b/engine-api/pom.xml index 46216858a..fd7aa75c0 100644 --- a/engine-api/pom.xml +++ b/engine-api/pom.xml @@ -92,23 +92,17 @@ org.apache.commons commons-lang3 - org.apache.commons commons-text - io.netty netty-handler - - - - perftests diff --git a/engine-docker/pom.xml b/engine-docker/pom.xml index 3476a55d1..5dad6b74f 100644 --- a/engine-docker/pom.xml +++ b/engine-docker/pom.xml @@ -35,12 +35,10 @@ - io.netty netty-handler - com.github.docker-java docker-java-api @@ -48,14 +46,15 @@ com.github.docker-java docker-java-core - 3.3.2 - + + com.fasterxml.jackson.core + jackson-databind + com.github.docker-java docker-java-transport-okhttp - com.github.docker-java docker-java diff --git a/engine-rest/pom.xml b/engine-rest/pom.xml deleted file mode 100644 index 620504c63..000000000 --- a/engine-rest/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - 4.0.0 - - - mvn-defaults - io.nosqlbench - ${revision} - ../mvn-defaults - - - engine-rest - jar - ${project.artifactId} - REST services for nosqlbench - - - UTF-8 - nosqlbench REST Services - - - - - - io.swagger.parser.v3 - swagger-parser - 2.1.15 - - - - io.swagger.core.v3 - swagger-models - 2.2.13 - - - - io.nosqlbench - engine-cli - ${revision} - - - - - diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/OpenApiEndpoint.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/OpenApiEndpoint.java deleted file mode 100644 index 7e15c8242..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/OpenApiEndpoint.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.resources; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import io.nosqlbench.docsys.api.WebServiceObject; -import io.nosqlbench.engine.rest.services.openapi.OpenApiLoader; -import io.nosqlbench.nb.annotations.Service; -import io.swagger.parser.OpenAPIParser; -import io.swagger.util.Json; -import io.swagger.v3.parser.converter.SwaggerConverter; -import jakarta.inject.Singleton; -import jakarta.ws.rs.*; -import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.Response; - -import java.util.Map; - -@Service(value = WebServiceObject.class, selector = "openapi") -@Singleton -@Path("/openapi") -public class OpenApiEndpoint implements WebServiceObject { - - private final OpenAPIParser parser = new OpenAPIParser(); - private final SwaggerConverter converter = new SwaggerConverter(); - private final Gson gson = new GsonBuilder().setPrettyPrinting().create(); - private final Json sjson = new Json(); - - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Path("generate") - public Response putWorkload(String input) { - try { - return Response - .ok("received " + input.length() + " length request. Phase 2 implemention on the way...") - .build(); - } catch (Exception e) { - return Response - .serverError() - .entity(e.getMessage()) - .build(); - } - } - - @GET - @Path("paths") - @Produces(MediaType.APPLICATION_JSON) - public Response listPaths(@QueryParam("filepath") String filepath) { - - try { - Map map = OpenApiLoader.parseToMap(filepath); - return Response.ok(Json.pretty(map)).build(); - - } catch (Exception e) { - return Response.serverError().entity(e.getMessage()).build(); - } - } - - -// private String toJson(String method, String path, Operation op) { -// try { -// LinkedHashMap map = new LinkedHashMap<>(); -// map.put("id", method.toUpperCase() + " " + path); -// map.put("path", path); -// map.put("method", method); -// map.put("description", op.getDescription()); -// map.put("summary",op.getSummary()); -// map.put("body",op.getRequestBody()); -// map.put("parameters",op.getParameters()); -// map.put("operation_id",op.getOperationId()); -// map.put("external_docs",op.getExternalDocs()); -//// return gson.toJson(map); -// -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// } - -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/ScenarioExecutorEndpoint.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/ScenarioExecutorEndpoint.java deleted file mode 100644 index 312e4bf5e..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/ScenarioExecutorEndpoint.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright (c) 2022-2023 nosqlbench - * - * 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 io.nosqlbench.engine.rest.resources; - -import io.nosqlbench.docsys.api.WebServiceObject; -import io.nosqlbench.engine.cli.BasicScriptBuffer; -import io.nosqlbench.engine.cli.Cmd; -import io.nosqlbench.engine.cli.NBCLICommandParser; -import io.nosqlbench.engine.cli.ScriptBuffer; -import io.nosqlbench.engine.core.lifecycle.ExecutionMetricsResult; -import io.nosqlbench.engine.core.lifecycle.scenario.Scenario; -import io.nosqlbench.engine.core.lifecycle.scenario.ScenariosExecutor; -import io.nosqlbench.engine.rest.services.WorkSpace; -import io.nosqlbench.engine.rest.services.WorkspaceFinder; -import io.nosqlbench.engine.rest.transfertypes.LiveScenarioView; -import io.nosqlbench.engine.rest.transfertypes.RunScenarioRequest; -import io.nosqlbench.nb.annotations.Maturity; -import io.nosqlbench.nb.annotations.Service; -import jakarta.inject.Singleton; -import jakarta.ws.rs.*; -import jakarta.ws.rs.core.*; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.joda.time.DateTime; -import org.joda.time.format.DateTimeFormat; - -import java.io.CharArrayWriter; -import java.io.PrintWriter; -import java.util.*; -import java.util.concurrent.Future; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -@Service(value = WebServiceObject.class, selector = "scenario-executor") -@Singleton -@Path("/services/executor/") -public class ScenarioExecutorEndpoint implements WebServiceObject { - private final static Logger logger = LogManager.getLogger(ScenarioExecutorEndpoint.class); - - private final ScenariosExecutor executor = new ScenariosExecutor("executor-service", 1); - - @Context - private Configuration config; - - - @DELETE - @Path("scenario/{scenario}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public synchronized Response cancelScenario(@PathParam("scenario") String scenario) { - try { - executor.deleteScenario(scenario); - return Response.ok("canceled '" + scenario + "' and removed it").build(); - } catch (Exception e) { - return Response.serverError().entity(e.getMessage()).build(); - } - } - - @POST - @Path("stop/{scenario}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public synchronized Response stopScenario(@PathParam("scenario") String scenario) { - try { - executor.stopScenario(scenario, false); - return Response.ok("stopped '" + scenario + "' without removing it").build(); - } catch (Exception e) { - return Response.serverError().entity(e.getMessage()).build(); - } - } - - - /** - * Run a NoSQLBench command just as you would on the command line. Certain parameters are translated - * (virtualized) into the workspace view for you automatically. That is, any path which would otherwise - * be resolved on the local file system will now be resolved in that same way but with the designated workspace - * as the base directory. All filesystem interaction which would otherwise happen in the current working - * directory should also be done relative to the designated workspace. - * @param rq - * @return - */ - @POST - @Path("cli") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public synchronized Response invokeCommand(RunScenarioRequest rq) { - - String name = rq.getScenarioName(); - - if (name.equals("auto")) { - rq.setScenarioName("scenario" + System.currentTimeMillis()); - } - org.joda.time.format.DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMddHHmmssSSS"); - name = name.replaceAll("EPOCHMS", String.valueOf(System.currentTimeMillis())); - name = name.replaceAll("DATESTAMP", dtf.print(new DateTime())); - name = name.replaceAll("[:/ ]", ""); - rq.setScenarioName(name); - - WorkSpace workspace = new WorkspaceFinder(config).getWorkspace(rq.getWorkspace()); - - // First, virtualize files provided - storeFiles(rq); - - LinkedList cmdList = new LinkedList<>(); - LinkedList args = new LinkedList<>(rq.getCommands()); - - for (String arg : args) { - if (arg.startsWith("-")) { - throw new RuntimeException("Only commands (verbs and params) can be used here"); - } - } - - args = substituteFilenames(rq, args); - Optional> parsed = NBCLICommandParser.parse(args, workspace.asIncludes()); - if (!parsed.isPresent()) { - return Response.serverError().entity("Unable to render command stream from provided command spec.").build(); - } - ScriptBuffer buffer = new BasicScriptBuffer(); - buffer.add(cmdList.toArray(new Cmd[0])); - - Scenario scenario = new Scenario( - rq.getScenarioName(), - "", - Scenario.Engine.Graalvm, - "disabled", - true, - false, - "", - cmdList.toString(), - (java.nio.file.Path) config.getProperties().get("logpath"), - Maturity.Unspecified); - - scenario.addScriptText(buffer.getParsedScript()); - - executor.execute(scenario); - - return Response.created(UriBuilder.fromResource(ScenarioExecutorEndpoint.class).path( - "scenario/" + rq.getScenarioName()).build()).entity("started").build(); - - } - - private LinkedList substituteFilenames(RunScenarioRequest rq, LinkedList args) { - LinkedList newargs = new LinkedList<>(); - for (String arg : args) { - for (String s : rq.getFilemap().keySet()) { - Pattern basename = Pattern.compile(s); - String fullyQualifiedName = rq.getFilemap().get(s); - Matcher basenameMatcher = basename.matcher(arg); - StringBuilder newarg = new StringBuilder(); - while (basenameMatcher.find()) { - basenameMatcher.appendReplacement(newarg,fullyQualifiedName); - } - basenameMatcher.appendTail(newarg); - arg = newarg.toString(); - } - newargs.add(arg); - } - return newargs; - } - - private void storeFiles(RunScenarioRequest rq) { - Map filemap = rq.getFilemap(); - if (filemap == null) { - return; - } - - WorkspaceFinder ws = new WorkspaceFinder(config); - WorkSpace workspace = ws.getWorkspace(rq.getWorkspace()); - - Map replacements = new HashMap<>(); - - for (String filename : filemap.keySet()) { - java.nio.file.Path targetPath = workspace.storeFile(filename, filemap.get(filename), replacements); - } - rq.setFileMap(replacements); - } - -// /** -// * Run a single-activity scenario -// * -// * @param scenarioName -// * The name to install in the executor -// * @param params -// * The params for the activity -// * -// * @return -// */ -// @POST -// @Path("scenario/{scenarioName}") -// @Consumes(MediaType.APPLICATION_JSON) -// @Produces(MediaType.APPLICATION_JSON) -// public synchronized Response invokeScenario( -// @PathParam("scenarioName") String scenarioName, -// Map params) { -// Scenario scenario = null; -// Optional pendingScenario = executor.getPendingScenario(scenarioName); -// if (pendingScenario.isPresent()) { -// scenario = pendingScenario.orElseThrow(); -// } else { -// scenario = new Scenario(scenarioName, Scenario.Engine.Graalvm); -// } -// if (params.containsKey("yamldoc")) { -// try { -// java.nio.file.Path tmpyaml = Files.createTempFile(Paths.get("/tmp"), scenarioName, ".yaml"); -// // TODO: Find a better way to do this, like scoping resources to executor -// tmpyaml.toFile().deleteOnExit(); -// Files.write(tmpyaml, params.get("yamldoc").getBytes(StandardCharsets.UTF_8)); -// params.remove("yamldoc"); -// params.put("yaml", tmpyaml.toString()); -// } catch (IOException e) { -// throw new RuntimeException(e); -// } -// } -// scenario.getScenarioController().apply(params); -// URI scenarioUri = UriBuilder.fromResource(ScenarioExecutorService.class) -// .build(scenarioName); -// return Response.created(scenarioUri).build(); -// } - - /** - * Return a view of a named scenario, just as with {@link #getScenarios()}}. - * If the named scenario is not present, an error will be returned instead. - * @param scenarioName - * @return - */ - @GET - @Path("scenario/{scenarioName}") - @Produces(MediaType.APPLICATION_JSON) - public synchronized LiveScenarioView getScenario(@PathParam("scenarioName") String scenarioName) { - Optional pendingScenario = executor.getPendingScenario(scenarioName); - - if (pendingScenario.isPresent()) { - Optional> pendingResult = executor.getPendingResult(scenarioName); - Future scenarioResultFuture = pendingResult.get(); - return new LiveScenarioView(pendingScenario.get()); - } else { - throw new RuntimeException("Scenario name '" + scenarioName + "' not found."); - } - } - - /** - * @return a view of all the scenarios known to the scenarios executor, whether starting, - * running, errored or otherwise. If the scenario is completed, then the result, - * including the IO log will be provided, otherwise an exception to explain why it failed. - */ - @GET - @Path("scenarios") - @Produces(MediaType.APPLICATION_JSON) - public synchronized Response getScenarios() { - - try { - List liveScenarioViews = new ArrayList<>(); - List pendingScenarios = executor.getPendingScenarios(); - - for (String pendingScenario : pendingScenarios) { - LiveScenarioView liveScenarioView = getScenario(pendingScenario); - liveScenarioViews.add(liveScenarioView); - } - return Response.ok(liveScenarioViews).build(); - } catch (Exception e) { - - CharArrayWriter caw = new CharArrayWriter(); - PrintWriter pw = new PrintWriter(caw); - e.printStackTrace(pw); - String trace = caw.toString(); - return Response.serverError().entity(trace).build(); - } - } - - -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/ServiceStatusEndpoint.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/ServiceStatusEndpoint.java deleted file mode 100644 index 08c4d7e13..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/ServiceStatusEndpoint.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.resources; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.nosqlbench.docsys.api.WebServiceObject; -import io.nosqlbench.nb.annotations.Service; -import io.nosqlbench.virtdata.userlibs.apps.docsapp.AutoDocsWebService; -import jakarta.inject.Singleton; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.QueryParam; -import jakarta.ws.rs.core.Configuration; -import jakarta.ws.rs.core.Context; -import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.Response; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.Map; - -@Service(value = WebServiceObject.class, selector = "service-status") -@Singleton -@Path("/services/status") -public class ServiceStatusEndpoint implements WebServiceObject { - private final static Logger logger = LogManager.getLogger(AutoDocsWebService.class); - - @Context - private Configuration config; - - @GET - @Produces(MediaType.APPLICATION_JSON) - - public Response isEnabled(@QueryParam("enabled") String overideEnabled) { - boolean enabled = false; - try { - if (overideEnabled != null) { - enabled = Boolean.parseBoolean(overideEnabled); - } - StatusEncoding status = new StatusEncoding(true, Map.of( - "status", "ORIGIN/services/status" - )); - return Response.ok(status).build(); - } catch (Exception e) { - return Response.serverError().entity(e.getMessage()).build(); - } - } - - private final static class StatusEncoding { - @JsonProperty("enabled") - public boolean isEnabled() { - return enabled; - } - - @JsonProperty("endpoints") - public Map getEndpoints() { - return endpoints; - } - - private final boolean enabled; - private final Map endpoints; - - public StatusEncoding(boolean enabled, Map endpoints) { - this.enabled = enabled; - this.endpoints = endpoints; - } - } -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/WorkloadFinderEndpoint.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/WorkloadFinderEndpoint.java deleted file mode 100644 index 38b891c4e..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/WorkloadFinderEndpoint.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.resources; - -import io.nosqlbench.docsys.api.WebServiceObject; -import io.nosqlbench.engine.api.scenarios.NBCLIScenarioParser; -import io.nosqlbench.engine.api.scenarios.WorkloadDesc; -import io.nosqlbench.engine.rest.services.WorkspaceFinder; -import io.nosqlbench.nb.annotations.Service; -import io.nosqlbench.virtdata.userlibs.apps.docsapp.AutoDocsWebService; -import jakarta.inject.Singleton; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.QueryParam; -import jakarta.ws.rs.core.Configuration; -import jakarta.ws.rs.core.Context; -import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.Response; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -@Service(value= WebServiceObject.class, selector="workload-finder") -@Singleton -@Path("/services/workloads") -public class WorkloadFinderEndpoint implements WebServiceObject { - private final static Logger logger = LogManager.getLogger(AutoDocsWebService.class); - - @Context - private Configuration config; - - public List getWorkloads(String search) { - return getWorkloads(Set.of(search!=null ? search.split(",") : new String[0])); - } - - public List getWorkloads(Set search) { - List workloads = new ArrayList<>(); - WorkspaceFinder ws = new WorkspaceFinder(config); - - for (String include : search) { - if (include.equals("builtins")) { - List activities = NBCLIScenarioParser.getWorkloadsWithScenarioScripts(true, "activities"); - for (WorkloadDesc desc : activities) { - workloads.add(desc); - } - } else { - List descInWorkspace = ws.getWorkspace(include).getWorkloadsWithScenarioScripts(); - for (WorkloadDesc workload : descInWorkspace) { - workloads.add(workload); - } - } - } - return workloads; - } - - - @GET - @Produces(MediaType.APPLICATION_JSON) - public Response getWorkloadDescriptions(@QueryParam("searchin") String searchin) { - WorkspaceFinder ws = new WorkspaceFinder(config); - Set searchIn = Set.of(searchin != null ? searchin.split(",") : new String[]{}); - - try { - List workloads = getWorkloads(searchIn); - return Response.ok(workloads).build(); - } catch (Exception e) { - return Response.serverError().entity(e.getMessage()).build(); - } - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - @Path("parameters") - public Map getParametersByWorkload( - @QueryParam("workloadName") String workloadName, - @QueryParam("searchin") String searchin - ) { - List workloads = getWorkloads(searchin); - - Map templates = null; - - templates = workloads.stream() - .filter(workload -> workload.getWorkloadName().equals(workloadName)) - .map(workload -> workload.getTemplates()) - .collect(Collectors.toSet()).iterator().next(); - - return templates; - } - -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/WorkspacesEndpoint.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/WorkspacesEndpoint.java deleted file mode 100644 index 919ffd335..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/resources/WorkspacesEndpoint.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.resources; - -import io.nosqlbench.docsys.api.WebServiceObject; -import io.nosqlbench.engine.rest.services.WorkSpace; -import io.nosqlbench.engine.rest.services.WorkspaceFinder; -import io.nosqlbench.engine.rest.transfertypes.WorkspaceItemView; -import io.nosqlbench.engine.rest.transfertypes.WorkspaceView; -import io.nosqlbench.nb.annotations.Service; -import jakarta.inject.Singleton; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.ws.rs.*; -import jakarta.ws.rs.core.*; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.nio.ByteBuffer; -import java.nio.file.Paths; -import java.util.List; -import java.util.stream.Collectors; - -@Service(value= WebServiceObject.class, selector="workspaces") -@Path("/services/workspaces") -@Singleton -public class WorkspacesEndpoint implements WebServiceObject { - - private final static Logger logger = LogManager.getLogger(WorkspacesEndpoint.class); - - @Context - private Configuration config; - - private final static java.nio.file.Path workspacesRoot = Paths.get("workspaces"); - private WorkspaceFinder svc; - - /** - * @return A list of workspaces as a - * {@link List} of {@link WorkspaceView} - */ - @GET - @Produces(MediaType.APPLICATION_JSON) - public Response getWorkspacesInfo() { - List wsviews = getSvc().getWorkspaceViews(); - return Response.ok(wsviews).build(); - } - - @DELETE - @Path("/{workspace}") - @Produces(MediaType.APPLICATION_JSON) - public Response deleteWorkspace(@PathParam("workspace") String workspace, - @QueryParam("deleteCount") String deleteCount) { - try { - int dc = deleteCount != null ? Integer.valueOf(deleteCount) : 0; - getSvc().purgeWorkspace(workspace, dc); - return Response.ok("removed workspace " + workspace).build(); - } catch (Exception e) { - return Response.serverError().entity(e.getMessage()).build(); - } - } - - @GET - @Path("/{workspaceName}/{filepath:.+}") - public Response listFilesInWorkspace( - @PathParam("workspaceName") String workspaceName, - @PathParam("filepath") String filepath - ) { - try { - WorkSpace w = getSvc().getWorkspace(workspaceName); - List listing = w.getWorkspaceListingView(filepath); - return Response.ok(listing).build(); - } catch (Exception e) { - return Response.serverError().entity(e.getMessage()).build(); - } - } - - - @POST - @Path("/{workspaceName}/upload/{filepath}") - @Consumes(MediaType.MULTIPART_FORM_DATA) - public Response uploadFileIntoWorkspace( - ) { - return Response.ok().build(); - } - - @PUT - @Path("/{workspaceName}/{filepath:.+}") - @Consumes(MediaType.WILDCARD) - @Produces(MediaType.WILDCARD) - public Response doSomething(@Context HttpServletRequest request, byte[] input) { - logger.debug("Content-Type: {}", request.getContentType()); - logger.debug("Preferred output: {}", request.getHeader(HttpHeaders.ACCEPT)); - try { - String pathInfo = request.getPathInfo(); - String[] parts = pathInfo.split("/"); - String workspaceName = parts[parts.length - 2]; - String filename = parts[parts.length - 1]; - getSvc().putFile(workspaceName, filename, ByteBuffer.wrap(input)); - return Response.ok().build(); - } catch (Exception e) { - return Response.status(Response.Status.BAD_REQUEST).build(); - } - } - - @GET - @Path("/{workspace}") - @Produces(MediaType.APPLICATION_JSON) - public Response getWorkspaceInfo( - @PathParam("workspace") String workspace, - @QueryParam("ls") String ls, - @QueryParam("contains") String contains - ) { - try { - WorkSpace ws = getSvc().getWorkspace(workspace); - WorkspaceView wsview = ws.getWorkspaceView(); - if (ls != null && !ls.equalsIgnoreCase("false")) { - List listing = ws.getWorkspaceListingView(""); - if (contains != null) { - listing = listing.stream().filter(i -> i.contains(contains)).collect(Collectors.toList()); - } - wsview.setListing(listing); - } - return Response.ok(wsview).build(); - } catch (Exception e) { - return Response.serverError().entity(e.getMessage()).build(); - } - } - - - @GET - @Path("/{workspace}/{filename}") - public Response getFileInWorkspace( - @PathParam("workspace") String workspace, - @PathParam("filename") String filename, - @QueryParam("ls") String ls) { - - try { - if (ls != null && !ls.equalsIgnoreCase("false")) { - WorkSpace ws = getSvc().getWorkspace(workspace); - List listing = ws.getWorkspaceListingView(filename); - return Response.ok(listing).build(); - - } else { - WorkspaceFinder.FileInfo fileinfo = getSvc().readFile(workspace, filename); - if (fileinfo != null) { - return Response.ok(fileinfo.getPath().toFile(), fileinfo.getMediaType()).build(); - } else { - return Response.noContent().status(Response.Status.NOT_FOUND).build(); - } - } - } catch (Exception e) { - return Response.serverError().entity(e.getMessage()).build(); - } - } - - private WorkspaceFinder getSvc() { - if (svc == null) { - svc = new WorkspaceFinder(config); - } - return svc; - } - -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/WorkSpace.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/WorkSpace.java deleted file mode 100644 index 705579a55..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/WorkSpace.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2022-2023 nosqlbench - * - * 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 io.nosqlbench.engine.rest.services; - -import io.nosqlbench.engine.api.activityconfig.rawyaml.RawYamlLoader; -import io.nosqlbench.engine.api.scenarios.NBCLIScenarioParser; -import io.nosqlbench.engine.api.scenarios.WorkloadDesc; -import io.nosqlbench.engine.rest.transfertypes.WorkspaceItemView; -import io.nosqlbench.engine.rest.transfertypes.WorkspaceView; -import io.nosqlbench.api.content.Content; -import io.nosqlbench.api.content.NBIO; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.nio.file.*; -import java.nio.file.attribute.PosixFilePermissions; -import java.util.ArrayList; -import java.util.Base64; -import java.util.List; -import java.util.Map; - -public class WorkSpace { - private final Path workspacesRoot; - private final Path workspacePath; - private final String workspaceName; - - public WorkSpace(Path workspacesRoot, String workspaceName) { - this.workspacesRoot = workspacesRoot; - this.workspaceName = workspaceName; - this.workspacePath = workspacesRoot.resolve(workspaceName); - if (!Files.exists(workspacePath)) { - try { - Files.createDirectories(workspacePath); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - - public WorkspaceView getWorkspaceView() { - return new WorkspaceView(workspacesRoot.resolve(workspaceName)); - } - - public Path getWorkspacePath() { - return workspacePath; - } - - public List getWorkloadsWithScenarioScripts() { - List> candidates = NBIO.fs().prefix(this.getWorkspacePath().toString()).extension(RawStmtsLoader.YAML_EXTENSIONS).list(); - List workloads = NBCLIScenarioParser.filterForScenarios(candidates); - List relativized = new ArrayList<>(); - for (WorkloadDesc workload : workloads) { - WorkloadDesc relative = workload.relativize(getWorkspacePath()); - relativized.add(relative); - } - return relativized; - } - - public Path storeFile(String filespec, String encoded, Map replacements) { - - String encoding = "raw"; - String filename = filespec; - - String[] parts = filespec.split(":", 2); - if (parts.length == 2) { - filename = parts[0]; - encoding = parts[1].toLowerCase(); - } - - - List openOptions = new ArrayList<>(); - - if (filename.startsWith(">>")) { - filename = filename.substring(">>".length()); - openOptions.add(StandardOpenOption.CREATE); - openOptions.add(StandardOpenOption.APPEND); - } else if (filename.startsWith(">")) { - filename = filename.substring(">".length()); - openOptions.add(StandardOpenOption.TRUNCATE_EXISTING); - openOptions.add(StandardOpenOption.CREATE); - } - - Path targetPath = Paths.get(filename); - assertLegalWorkspacePath(targetPath); - - if (targetPath.isAbsolute()) { - throw new RuntimeException("You may not use absolute paths in workspaces: '" + targetPath + "'"); - } - targetPath = this.workspacePath.resolve(targetPath); - - ByteBuffer content; - - switch (encoding) { - case "raw": - content = ByteBuffer.wrap(encoded.getBytes(StandardCharsets.UTF_8)); - break; - case "base64": - byte[] bytes = Base64.getDecoder().decode(encoded); - content = ByteBuffer.wrap(bytes); - break; - default: - throw new RuntimeException("Unrecognized encoding of file data '" + encoding + "'"); - } - - try { - Files.createDirectories( - targetPath.getParent(), - PosixFilePermissions.asFileAttribute( - PosixFilePermissions.fromString("rwxr-x---") - )); - Files.write(targetPath, content.array(), openOptions.toArray(new OpenOption[0])); - replacements.put(filename,targetPath.toString()); - return targetPath; - } catch (Exception e) { - throw new RuntimeException(e); - } - - } - - public List getWorkspaceListingView(String filepath) { - - Path target = this.workspacePath.resolve(filepath); - assertLegalWorkspacePath(target); - - List items = new ArrayList<>(); - - try (DirectoryStream elementPaths = Files.newDirectoryStream(target)) { - for (Path elementPath : elementPaths) { - items.add(new WorkspaceItemView(this.workspacePath,elementPath)); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - - return items; - } - - private void assertLegalWorkspacePath(Path target) { - if (!target.normalize().startsWith(this.workspacePath)) { - throw new RuntimeException("workspace path '" + target + "' contains path traversal"); - } - if (target.toString().contains("..")) { - throw new RuntimeException("Possible path injection:" + target); - } - } - - @Override - public String toString() { - return this.workspaceName; - } - - public String[] asIncludes() { - Path relativePath = - this.workspacesRoot.toAbsolutePath().getParent().relativize(this.workspacePath.toAbsolutePath()); - return new String[]{ relativePath.toString() }; - } -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/WorkspaceFinder.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/WorkspaceFinder.java deleted file mode 100644 index 768ac2805..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/WorkspaceFinder.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.services; - -import io.nosqlbench.engine.rest.transfertypes.WorkspaceView; -import jakarta.ws.rs.core.Configuration; -import jakarta.ws.rs.core.MediaType; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.file.*; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.stream.Stream; - -public class WorkspaceFinder { - private final static Logger logger = LogManager.getLogger(WorkspaceFinder.class); - - public static String DEFAULT = "default"; - public static final String WORKSPACE_ROOT = "workspaces_root"; - - private final Path root; - - public WorkspaceFinder(Configuration config) { - Object root = config.getProperties().get(WORKSPACE_ROOT); - if (root instanceof Path) { - this.root = (Path) root; - } else if (root instanceof CharSequence) { - this.root = Paths.get(((CharSequence) root).toString()); - } else if (root == null) { - this.root = Paths.get( - System.getProperty("user.dir"), - "workspaces" - ); - try { - Files.createDirectories(this.root); - } catch (IOException e) { - throw new RuntimeException(e); - } - } else { - throw new RuntimeException("Unable to use workspaces root " + - "path of type " + root.getClass().getCanonicalName()); - } - createDefaultIfNotExist(); - } - - public WorkspaceFinder(Path root) { - this.root = root; - createDefaultIfNotExist(); - } - - private void createDefaultIfNotExist() { - getWorkspaceView(DEFAULT); - } - - public List getWorkspaceViews() { - List views = new ArrayList<>(); - try (DirectoryStream wsrEntries = Files.newDirectoryStream(root)) { - for (Path entry : wsrEntries) { - views.add(new WorkspaceView(entry)); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - return views; - } - - public WorkSpace getWorkspace(String workspaceName) { - assertLegalWorkspaceName(workspaceName); - return new WorkSpace(this.root, workspaceName); - } - - public static void assertLegalWorkspaceName(String workspaceName) { - if (!workspaceName.matches("[a-zA-Z0-9]+")) { - throw new RuntimeException("Workspace names must contain only letters and numbers."); - } - } - - public WorkspaceView getWorkspaceView(String workspaceName) { - return getWorkspace(workspaceName).getWorkspaceView(); - } - - public void putFile(String workspaceName, String filename, ByteBuffer content) { - Path toWrite = root.resolve(workspaceName).resolve(filename); - try { - Files.write(toWrite, content.array(), - StandardOpenOption.TRUNCATE_EXISTING, - StandardOpenOption.CREATE, - StandardOpenOption.WRITE); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - /** - * Read the bytes of the named file in the named workspace. - * - * @param workspaceName The workspace name to look in for the file - * @param filename The filename within the workspace to read - * @return null if the file is not found - * @throws RuntimeException if the file was found but could not be - * read. - */ - public FileInfo readFile(String workspaceName, String filename) { - Path filePath = workspacePath(workspaceName).resolve(filename); - if (Files.exists(filePath)) { - return new FileInfo(filePath); - } else { - return null; - } - } - - private Path workspacePath(String workspaceName) { - return root.resolve(workspaceName); - } - - public void purgeWorkspace(String workspaceName, int deleteCount) { - assertLegalWorkspaceName(workspaceName); - Path path = workspacePath(workspaceName); - if (Files.exists(path)) { - try (Stream counter = Files.walk(path)) { - long foundFiles = counter.count(); - if (foundFiles > 100 && deleteCount != foundFiles) { - throw new RuntimeException( - "To delete " + foundFiles + " files, you must provide a deleteCount= " + - "parameter that matches. This is a safety mechanism." - ); - } - logger.debug(() -> "found " + foundFiles + " to delete."); - } catch (Exception e) { - throw new RuntimeException(e); - } - - Path relativize = root.relativize(path); - if (relativize.toString().contains("..")) { - throw new RuntimeException("Illegal path to delete: " + path); - } - - try (Stream walk = Files.walk(path)) { - walk.sorted(Comparator.reverseOrder()) - .map(Path::toFile) -// .peek(System.out::println) - .forEach(f -> { - logger.debug(() -> "deleting '" + f + "'"); - if (!f.delete()) { - throw new RuntimeException("Unable to delete " + f); - } - }); - - } catch (IOException e) { - throw new RuntimeException(e); - } - - } - } - - public final static class FileInfo { - private final Path path; - - public FileInfo(Path path) { - this.path = path; - } - - public MediaType getMediaType() { - try { - String contentType = Files.probeContentType(path); - MediaType mediaType = MediaType.valueOf(contentType); - return mediaType; - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public ByteBuffer getContent() { - byte[] bytes = new byte[0]; - try { - bytes = Files.readAllBytes(path); - } catch (IOException e) { - throw new RuntimeException(e); - } - return ByteBuffer.wrap(bytes); - } - - public Path getPath() { - return path; - } - } - -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/openapi/OpenApiLoader.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/openapi/OpenApiLoader.java deleted file mode 100644 index b736abedc..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/openapi/OpenApiLoader.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.services.openapi; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import io.nosqlbench.api.content.Content; -import io.nosqlbench.api.content.NBIO; -import io.swagger.parser.OpenAPIParser; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.Operation; -import io.swagger.v3.oas.models.PathItem; -import io.swagger.v3.oas.models.Paths; -import io.swagger.v3.parser.core.models.ParseOptions; -import io.swagger.v3.parser.core.models.SwaggerParseResult; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.introspector.BeanAccess; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * @see OpenApi Spec 3.1.0 - */ -public class OpenApiLoader { - private final static Logger logger = LogManager.getLogger(OpenApiLoader.class); - - private static final OpenAPIParser parser = new OpenAPIParser(); - private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); - - /** - * If it is not found, the Stargate path is used by default. - * - * For now, the json is used as a filter with the following conventions: - *
{@code
-     *   {
-     *       " ": {...},
-     *       ...
-     *   }
-     * }
- * - * The presence of a key with a matching method and path to one of those found - * in the openapi details indicates it should be included. - * - * @param openIdYamlPath a filepath is where an openapi descriptor can be found - * @param json The selection data used to filer in our out calls from the openapi descriptor - * @return A yaml workload which can be used with the http driver - */ - public static String generateWorkloadFromFilepath(String openIdYamlPath, String json) { - Map filter = gson.fromJson(json, Map.class); - Set included = filter.keySet().stream() - .map(Object::toString) - .collect(Collectors.toSet()); - - OpenAPI openAPI = parseOpenApi(openIdYamlPath); - Paths paths = openAPI.getPaths(); - - List allOps = new ArrayList<>(); - - for (String pathName : paths.keySet()) { - PathItem pathItem = paths.get(pathName); - List calls = PathOp.wrap(pathName, pathItem); - allOps.addAll(calls); - } - - List activeOps = allOps.stream() - .filter(op -> { - return included.contains(op.getCall()); - }) - .collect(Collectors.toList()); - - Map pathops = new HashMap<>(); - DumperOptions dumper = new DumperOptions(); - dumper.setAllowReadOnlyProperties(true); - Yaml yaml = new Yaml(dumper); - yaml.setBeanAccess(BeanAccess.DEFAULT); - - for (PathOp activeOp : activeOps) { - logger.debug(() -> "yaml for op:" + yaml.dump(activeOp)); - pathops.put(activeOp.getCall(), activeOp); - } - - String dump = yaml.dump(pathops); - return dump; - } - - public static OpenAPI parseOpenApi(String filepath) { - if (filepath == null) { - filepath = "stargate.yaml"; - } else if (!filepath.endsWith(".yaml")) { - throw new RuntimeException("Only .yaml filepaths are supported for now."); - } - - Content one = NBIO.all().name(filepath).one(); - String content = one.asString(); - SwaggerParseResult parsed = parser.readContents(content, List.of(), new ParseOptions()); - List messages = parsed.getMessages(); - if (messages.size() > 0) { - throw new RuntimeException("error while parsing: " + String.join("\n", messages.toArray(new String[0]))); - } - - OpenAPI openAPI = parsed.getOpenAPI(); - return new OpenApiView(openAPI).getDereferenced(); - } - - // TODO; use the op wrapper interface here - public static Map parseToMap(String filepath) { - OpenAPI openAPI = parseOpenApi(filepath); - - Paths paths = openAPI.getPaths(); - LinkedHashMap map = new LinkedHashMap<>(); - - for (String pathName : paths.keySet()) { - PathItem pathItem = paths.get(pathName); - - if (pathItem.getGet() != null) { - Operation op = pathItem.getGet(); - map.put("GET " + pathName, map("GET", pathName, op)); - } - if (pathItem.getPost() != null) { - Operation op = pathItem.getPost(); - map.put("POST " + pathName, map("POST", pathName, op)); - } - if (pathItem.getPut() != null) { - Operation op = pathItem.getPut(); - map.put("PUT " + pathName, map("PUT", pathName, op)); - } - if (pathItem.getPatch() != null) { - Operation op = pathItem.getPatch(); - map.put("PATCH " + pathName, map("PATCH", pathName, op)); - } - if (pathItem.getDelete() != null) { - Operation op = pathItem.getDelete(); - map.put("DELETE " + pathName, map("DELETE", pathName, op)); - } - if (pathItem.getHead() != null) { - Operation op = pathItem.getHead(); - map.put("HEAD " + pathName, map("HEAD", pathName, op)); - } - if (pathItem.getOptions() != null) { - Operation op = pathItem.getOptions(); - map.put("OPTIONS " + pathName, map("OPTIONS", pathName, op)); - } - } - return map; - } - - private static Map map(String method, String pathName, Operation op) { - LinkedHashMap map = new LinkedHashMap<>(); - - map.put("method", method); - map.put("path", pathName); - map.put("api", op); - map.put("summary", op.getSummary() != null ? op.getSummary() : ""); - map.put("description", op.getDescription() != null ? op.getDescription() : ""); - return map; - - } - -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/openapi/OpenApiView.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/openapi/OpenApiView.java deleted file mode 100644 index a8a0bde3e..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/openapi/OpenApiView.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.services.openapi; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.Operation; -import io.swagger.v3.oas.models.PathItem; -import io.swagger.v3.oas.models.Paths; -import io.swagger.v3.oas.models.headers.Header; -import io.swagger.v3.oas.models.links.Link; -import io.swagger.v3.oas.models.media.Schema; -import io.swagger.v3.oas.models.parameters.Parameter; -import io.swagger.v3.oas.models.parameters.RequestBody; -import io.swagger.v3.oas.models.responses.ApiResponse; -import io.swagger.v3.oas.models.responses.ApiResponses; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#pathsObject - */ -public class OpenApiView { - - private final OpenAPI model; - - public OpenApiView(OpenAPI model) { - this.model = model; - } - - public OpenAPI getDereferenced() { - - // Since links, parameters, and responses in components can have references, - // connect their references first - - resolveBodiesInLinks(); - resolveSchemasInParameters(); - resolveHeadersInResponses(); - -// OpenAPI out = new OpenAPI(); - Paths paths = model.getPaths(); - - for (String pathKey : paths.keySet()) { - PathItem pi = paths.get(pathKey); - if (pi.get$ref() != null) { - throw new RuntimeException("Unable to read external ref in this version for path '" + pathKey + "':'" - + pi.get$ref() + "'"); - } - - for (Operation op : new Operation[]{ - pi.getDelete(), - pi.getGet(), - pi.getPost(), - pi.getTrace(), - pi.getPatch(), - pi.getOptions(), - pi.getPut(), - pi.getHead() - }) { - if (op != null) { - flattenOperation(op); - } - } - - pi.setParameters(resolveParameterList(pi.getParameters())); - - } - return model; - } - - private void flattenOperation(Operation op) { - if (op.getResponses() != null) { - op.setResponses(resolveResponsesMap(op.getResponses())); - } - if (op.getParameters() != null) { - op.setParameters(resolveParameterList(op.getParameters())); - } - if (op.getRequestBody() != null) { - op.setRequestBody(resolveRequestBody(op.getRequestBody())); - } - } - - private RequestBody resolveRequestBody(RequestBody requestBody) { - while (requestBody.get$ref() != null) { - requestBody = model.getComponents().getRequestBodies().get(requestBody.get$ref()); - } - return requestBody; - } - - private List resolveParameterList(List parameters) { - if (parameters == null) { - return null; - } - List resolved = new ArrayList<>(); - for (Parameter p : parameters) { - p = resolve(p); - p.setSchema(resolveSchema(p.getSchema())); - resolved.add(p); - } - return resolved; - } - - private final static Map, String> componentPaths = - Map.of( - Parameter.class, "#/components/parameters/", - ApiResponse.class, "#/components/responses/" - ); - - private final static Map, String> mapMethods = - Map.of( - Parameter.class, "getParameters", - ApiResponse.class, "getResponses" - ); - - - private T resolve(T aliased) { - if (aliased == null) { - return null; - } - - String typepath = componentPaths.get(aliased.getClass()); - if (typepath == null) { - throw new RuntimeException("Could not find component path prefix for " + aliased.getClass().getCanonicalName()); - } - String mapMethod = mapMethods.get(aliased.getClass()); - if (mapMethod == null) { - throw new RuntimeException("Could not find map method for " + aliased.getClass().getCanonicalName()); - } - - T element = aliased; - int remaining = 100; - while (true) { - if (remaining <= 0) { - throw new RuntimeException("loop limit reached in resolving element"); - } - try { - Method getref = element.getClass().getMethod("get$ref"); - Object invoke = getref.invoke(element); - if (invoke == null) { - return element; - } - String refid = invoke.toString(); - - int idAt = refid.lastIndexOf("/"); - String name = refid.substring(idAt + 1); - String prefix = refid.substring(0, idAt + 1); - if (!prefix.equals(typepath)) { - throw new RuntimeException("wrong type path (" + typepath + ") for prefix '" + prefix + "'"); - } - Method getMap = model.getComponents().getClass().getMethod(mapMethod); - Object mapobj = getMap.invoke(model.getComponents()); - Map map = (Map) mapobj; - Object o = map.get(name); - element = (T) o; - } catch (Exception e) { - throw new RuntimeException("unable to call get$ref: " + aliased.getClass().getCanonicalName()); - } - } - } - - private Schema resolveSchema(Schema schema) { - while (schema.get$ref() != null) { - schema = model.getComponents().getSchemas().get(schema.get$ref()); - } - return schema; - } - - private ApiResponses resolveResponsesMap(ApiResponses responses) { - if (responses != null) { - for (String rk : responses.keySet()) { - ApiResponse response = responses.get(rk); - response = resolve(response); - - response.setHeaders(resolveHeaderMap(response.getHeaders())); - response.setExtensions(resolveExtensionsMap(response.getExtensions())); - response.setLinks(resolveLinksMap(response.getLinks())); - } - } - return responses; - } - - private Map resolveLinksMap(Map links) { - if (links != null) { - for (String lk : links.keySet()) { - Link link = links.get(lk); - while (link.get$ref() != null) { - link = model.getComponents().getLinks().get(link.get$ref()); - } - links.put(lk, link); - } - } - return links; - } - - private Map resolveExtensionsMap(Map extensions) { - if (extensions != null) { - if (extensions.keySet().size() > 0) { - throw new RuntimeException("extensions are not supported in this version"); - } - } - return extensions; - } - - private Map resolveHeaderMap(Map headers) { - if (headers != null) { - for (String hk : headers.keySet()) { - Header header = headers.get(hk); - while (header.get$ref() != null) { - header = model.getComponents().getHeaders().get(hk); - } - headers.put(hk, header); - } - } - return headers; - } - - private void resolveBodiesInLinks() { - Map links = model.getComponents().getLinks(); - if (links == null) { - return; - } - for (String linkKey : links.keySet()) { - Link modelLink = model.getComponents().getLinks().get(linkKey); - -// RequestBody body = modelLink.getRequestBody(); -// while (body.get$ref() != null) { -// body = model.getComponents().getRequestBodies().get(body.get$ref()); -// } - Object body = modelLink.getRequestBody(); - modelLink.setRequestBody(body); - } - } - - private void resolveSchemasInParameters() { - for (String parameterKey : model.getComponents().getParameters().keySet()) { - Parameter parameter = model.getComponents().getParameters().get(parameterKey); - Schema schema = parameter.getSchema(); - while (schema.get$ref() != null) { - schema = model.getComponents().getSchemas().get(schema.get$ref()); - } - parameter.setSchema(schema); - - } - } - - private void resolveHeadersInResponses() { - for (String responseKey : model.getComponents().getResponses().keySet()) { - ApiResponse response = model.getComponents().getResponses().get(responseKey); - Map modelHeaders = response.getHeaders(); - Map headers = new HashMap<>(); - - for (String headerKey : headers.keySet()) { - Header header = modelHeaders.get(headerKey); - while (header.get$ref() != null) { - header = modelHeaders.get(header.get$ref()); - } - headers.put(headerKey, header); - } - response.setHeaders(headers); - } - } - -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/openapi/PathOp.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/openapi/PathOp.java deleted file mode 100644 index 762def5da..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/openapi/PathOp.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.services.openapi; - -import io.swagger.v3.oas.models.Operation; -import io.swagger.v3.oas.models.PathItem; -import io.swagger.v3.oas.models.parameters.Parameter; - -import java.util.ArrayList; -import java.util.List; - -public class PathOp { - - private final String method; - private final String path; - private final Operation op; - - public PathOp(String method, String path, Operation op) { - this.method = method; - this.path = path; - this.op = op; - } - - public Operation getOp() { - return op; - } - - public static List wrap(String path, PathItem item) { - List methods = List.of("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD", "TRACE"); - Operation[] ops = new Operation[]{item.getGet(), item.getPost(), item.getPut(), item.getDelete(), - item.getPatch(), item.getOptions(), - item.getHead(), item.getTrace()}; - List pathops = new ArrayList<>(); - - for (int i = 0; i < methods.size(); i++) { - PathOp pathop = wrap(path, methods.get(i), ops[i]); - if (pathop != null) { - pathops.add(pathop); - } - } - return pathops; - } - - private static PathOp wrap(String path, String method, Operation op) { - if (op == null) { - return null; - } - return new PathOp(method, path, op); - } - - public Operation getOperation() { - return this.op; - } - - public String toString() { - String call = getMethod() + " " + getPath(); - if (getOperation().getParameters().size() > 0) { - for (Parameter p : getOperation().getParameters()) { - String name = p.getName(); - System.out.println("name: " + name); - } - } - return call; - } - - public String getPath() { - return this.path; - } - - public String getMethod() { - return this.method; - } - - public String getCall() { - return method.toUpperCase() + " " + path; - } -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/package-info.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/package-info.java deleted file mode 100644 index bf6cd56ef..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/services/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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. - */ - -/** - * Classes in this package are meant to provide a basic - * internal service facade to be used by endpoints. - * This simplifies endpoint implementations and facilitates DRY - * implementations. - * - * These implementations should only expose primitive types, - * collections of primitive types, or views of transfer types - * as implemented in that package. - */ -package io.nosqlbench.engine.rest.services; diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/LiveScenarioView.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/LiveScenarioView.java deleted file mode 100644 index 2af423f65..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/LiveScenarioView.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.transfertypes; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyDescription; -import io.nosqlbench.engine.api.activityapi.core.progress.ProgressMeterDisplay; -import io.nosqlbench.engine.core.lifecycle.scenario.Scenario; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class LiveScenarioView { - - private final Scenario scenario; - - public LiveScenarioView(Scenario scenario) { - this.scenario = scenario; - } - - @JsonProperty - @JsonPropertyDescription("Optionally populated result, "+ - " present only if there was an error or the scenario is complete") - public ResultView getResult() { - return new ResultView(scenario.getResultIfComplete().orElse(null)); - } - - @JsonProperty("scenario_name") - public String getScenarioName() { - return scenario.getScenarioName(); - } - - @JsonProperty("started_at") - public long getStartMillis() { - return scenario.getStartedAtMillis(); - } - - @JsonProperty("ended_at") - public long getEndMillis() { - return scenario.getEndedAtMillis(); - } - - public Scenario.State getState() { - return scenario.getScenarioState(); - } - - @JsonProperty("progress") - public List getProgress() { - List progressView = new ArrayList<>(); - if (scenario.getScenarioController()==null) { - return progressView; - } - - Collection meters = scenario.getScenarioController().getProgressMeters(); - for (ProgressMeterDisplay progressMeterDisplay : meters) { - ProgressView meterView = new ProgressView(progressMeterDisplay); - progressView.add(meterView); - } - - return progressView; - } - -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/ProgressView.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/ProgressView.java deleted file mode 100644 index 4edd2369a..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/ProgressView.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.transfertypes; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.nosqlbench.engine.api.activityapi.core.progress.CycleMeter; -import io.nosqlbench.engine.api.activityapi.core.progress.ProgressMeterDisplay; -import io.nosqlbench.engine.api.activityapi.core.progress.StateCapable; - -public class ProgressView { - - private final ProgressMeterDisplay progressMeterDisplay; - - public ProgressView(ProgressMeterDisplay progressMeterDisplay) { - if (progressMeterDisplay ==null) { - throw new RuntimeException("Unable to create a view with a null progressMeter"); - } - this.progressMeterDisplay = progressMeterDisplay; - } - - @JsonProperty("summary") - public String getProgressDetails() { - return progressMeterDisplay.getSummary(); - } - - @JsonProperty("min") - public double getMin() { - return progressMeterDisplay.getMinValue(); - } - - @JsonProperty("current") - public double getCurrent() { - return progressMeterDisplay.getCurrentValue(); - } - - @JsonProperty("max") - public double getMax() { - return progressMeterDisplay.getMaxValue(); - } - - - @JsonProperty("recycles_max") - public double getRecyclesMax() { - if (progressMeterDisplay instanceof CycleMeter cm) { - return cm.getRecyclesMax(); - } else { - return Double.NaN; - } - } - - @JsonProperty("recycles_current") - public double getRecyclesCurrent() { - if (progressMeterDisplay instanceof CycleMeter cm) { - return cm.getRecyclesCurrent(); - } else { - return Double.NaN; - } - } - - @JsonProperty("eta_millis") - public double getEtaMills() { - return progressMeterDisplay.getProgressETAMillis(); - } - - @JsonProperty("name") - public String getName() { - return progressMeterDisplay.getProgressName(); - } - - @JsonProperty("completed") - public double getProgress() { - return progressMeterDisplay.getRatioComplete(); - } - - @JsonProperty("state") - public String getState() { - if (progressMeterDisplay instanceof StateCapable) { - return ((StateCapable) progressMeterDisplay).getRunState().toString(); - } else { - return "unknown"; - } - } - - -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/ResultView.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/ResultView.java deleted file mode 100644 index 9bf85980f..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/ResultView.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.transfertypes; - -import io.nosqlbench.engine.core.lifecycle.ExecutionMetricsResult; - -public class ResultView { - - private final ExecutionMetricsResult result; - - public ResultView(ExecutionMetricsResult result) { - this.result = result; - } - - public String getIOLog() { - if (result != null) { - return result.getIOLog(); - } else { - return ""; - } - } - - public String getError() { - if (result != null && result.getException()!=null) { - return result.getException().getMessage(); - } - return ""; - } -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/RunScenarioRequest.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/RunScenarioRequest.java deleted file mode 100644 index 35072e752..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/RunScenarioRequest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.transfertypes; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.Map; - -public class RunScenarioRequest { - - @JsonProperty("commands") - private List commands = List.of(); - - @JsonProperty("filemap") - private Map filemap = Map.of(); - - @JsonProperty("console") - private String stdout; - - @JsonProperty("scenario_name") - private String scenarioName = "auto"; - - @JsonProperty("workspace") - private String workspace = "default"; - - public String getWorkspace() { - return workspace; - } - - public void setWorkspace(String workspace) { - this.workspace = workspace; - } - - public void setScenarioName(String scenarioName) { - this.scenarioName = scenarioName; - } - - public String getScenarioName() { - return scenarioName; - } - - public void setCommands(List commands) { - this.commands = commands; - } - - public void setFileMap(Map filemap) { - this.filemap = filemap; - } - - public void setStdout(String stdout) { - this.stdout = stdout; - } - - public List getCommands() { - return commands; - } - - public Map getFilemap() { - return filemap; - } - - public String getStdout() { - return stdout; - } - -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/WorkloadsView.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/WorkloadsView.java deleted file mode 100644 index c1dc70b2a..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/WorkloadsView.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.transfertypes; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.nosqlbench.engine.api.scenarios.WorkloadDesc; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class WorkloadsView { - private final Map> workloadsByWorkspace = new HashMap<>(); - - @JsonProperty("workloads") - public Map> getWorkloads() { - return workloadsByWorkspace; - } - - public void add(String workspace, WorkloadDesc workload) { - workloadsByWorkspace.computeIfAbsent(workspace, ws -> new ArrayList<>()).add(workload); - } - - public void addAll(String workspace, List workloads) { - workloadsByWorkspace.computeIfAbsent(workspace,ws -> new ArrayList<>()).addAll(workloads); - } -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/WorkspaceItemView.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/WorkspaceItemView.java deleted file mode 100644 index ccd12ecbe..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/WorkspaceItemView.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.transfertypes; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.attribute.FileOwnerAttributeView; -import java.nio.file.attribute.PosixFileAttributeView; -import java.nio.file.attribute.PosixFileAttributes; -import java.nio.file.attribute.PosixFilePermission; -import java.util.List; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -public class WorkspaceItemView { - - private final Path _path; - private String type; - private String perms; - private String owner; - private String group; - private long size; - private long mtime; - - private final static List fields = List.of( - "type", - "perms", - "owner", - "group", - "size", - "mtime", - "name" - ); - - public WorkspaceItemView(Path wspath, Path path) { - try { - PosixFileAttributeView posix = Files.getFileAttributeView(path, PosixFileAttributeView.class); - PosixFileAttributes attrs = posix.readAttributes(); - - setPerms(fromPerms(attrs.permissions())); - setType(typeOf(path)); - setOwner(attrs.owner().getName()); - setGroup(attrs.group().getName()); - setSize(attrs.size()); - setMtimeMillis(attrs.lastModifiedTime().to(TimeUnit.MILLISECONDS)); - setName(wspath.relativize(path).toString()); - this._path = path; - - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - - private void setOwner(FileOwnerAttributeView fileAttributeView) { - try { - this.setOwner(fileAttributeView.getOwner().getName()); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private String typeOf(Path path) { - if (Files.isRegularFile(path)) { - return "F"; - } - if (Files.isDirectory(path)) { - return "D"; - } - return "U"; - } - - @JsonProperty("fields") - public List> getAsFields() { - return List.of( - fields, - List.of( - this.type, - this.perms, - this.owner, - this.group, - String.valueOf(this.size), - "mtime", - this.name - ) - ); - - } - private String fromPerms(Set perms) { - StringBuilder sb = new StringBuilder(); - String img = "rwxrwxrwx"; - String not = "---------"; - int step = 0; - for (PosixFilePermission perm : PosixFilePermission.values()) { - String src = perms.contains(perm) ? img : not; - sb.append(src.charAt(step)); - step++; - } - return sb.toString(); - } - - public String getPerms() { - return perms; - } - - public void setPerms(String perms) { - this.perms = perms; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getGroup() { - return group; - } - - public void setGroup(String group) { - this.group = group; - } - - public long getSize() { - return size; - } - - public void setSize(long size) { - this.size = size; - } - - public long getMtimeMillis() { - return mtime; - } - - public void setMtimeMillis(long mtime) { - this.mtime = mtime; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - private String name; - - public boolean contains(String content) { - if (!Files.isRegularFile(_path)) { - return false; - } - try { - String s = Files.readString(this._path); - return s.matches("(?s)" + content); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/WorkspaceView.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/WorkspaceView.java deleted file mode 100644 index e9c349590..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/WorkspaceView.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.transfertypes; - -import com.fasterxml.jackson.annotation.JsonProperty; -import org.joda.time.Period; -import org.joda.time.format.PeriodFormatter; -import org.joda.time.format.PeriodFormatterBuilder; - -import java.io.IOException; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.List; - -public class WorkspaceView { - - private final static PeriodFormatter pf = new PeriodFormatterBuilder() - .appendWeeks().appendSuffix(" week", " weeks").appendSeparator(" ") - .appendDays().appendSuffix(" day", " days").appendSeparator(" ") - .appendHours().appendSuffix("H") - .appendMinutes().appendSuffix("M") - .appendSeconds().appendSuffix("S") - .toFormatter(); - - private final Path workspaceRoot; - private Summary summary; - - @JsonProperty("ls") - private List listing = null; - - public WorkspaceView(Path workspaceRoot) { - this.workspaceRoot = workspaceRoot; - } - - public String getName() { - return workspaceRoot.getFileName().toString(); - } - - @JsonProperty("modified") - public long getModified() { - try { - return Files.getLastModifiedTime(workspaceRoot).toMillis(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @JsonProperty("summary") - public Summary getSummary() { - if (this.summary == null) { - Summary v = new Summary(this.workspaceRoot); - try { - Files.walkFileTree(this.workspaceRoot, v); - this.summary = v; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - return this.summary; - } - - public void setListing(List listing) { - this.listing = listing; - } - - public final static class Summary extends SimpleFileVisitor { - - private final Path root; - - public long total_bytes = 0L; - public long total_files = 0L; - public long last_changed_epoch = Long.MIN_VALUE; - public String last_changed_filename = ""; - - public String getLast_changed_ago() { - int millis = (int) (System.currentTimeMillis() - last_changed_epoch); - Period period = Period.millis(millis); - return pf.print(period.normalizedStandard()); - } - - public Summary(Path root) { - this.root = root; - } - - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - total_bytes += Files.size(file); - total_files++; - long millis= Files.getLastModifiedTime(file).toMillis(); - if (last_changed_epoch getWorkspaces() { - List workspaces = new ArrayList<>(); - try (DirectoryStream paths = Files.newDirectoryStream(workspacesRoot)) { - for (Path path : paths) { - workspaces.add(path.toString()); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - return workspaces; - } -} diff --git a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/package-info.java b/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/package-info.java deleted file mode 100644 index cd347b0fd..000000000 --- a/engine-rest/src/main/java/io/nosqlbench/engine/rest/transfertypes/package-info.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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. - */ - -/** - * Types in this package are meant to provide a mapping - * between internal state and external views. Specifically, - * these types should only include details which are meant to - * be shared by endpoints. This can be achieved by wrapping - * internal state and exposing only the visible properties, or - * it can be done by implementing types which are built from - * common internal types. - * - * Service objects in the services package should only provide - * primitive values or the view types from this package. - */ -package io.nosqlbench.engine.rest.transfertypes; diff --git a/engine-rest/src/main/resources/stargate.yaml b/engine-rest/src/main/resources/stargate.yaml deleted file mode 100644 index 9338df46c..000000000 --- a/engine-rest/src/main/resources/stargate.yaml +++ /dev/null @@ -1,1789 +0,0 @@ -openapi: 3.0.1 -info: - title: Stargate REST on Astra - description: "" - license: - name: Apache 2.0 - url: http://www.apache.org/licenses/LICENSE-2.0.html - version: 2.0.0 -servers: - - url: https://{databaseId}-{region}.apps.astra.datastax.com -externalDocs: - description: Reference Document - url: http://shorturl.at/hnqIQ -tags: - - name: auth - description: auth - - name: namespaces - description: document data - - name: keyspaces - description: tablular data - - name: schemas - description: storage configuration -paths: - /api/rest/v1/auth: - post: - tags: - - auth - summary: Create an auth token - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/Credentials" - required: true - responses: - 201: - description: Created - content: - application/json: - examples: - default: - value: { "authToken": "string" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/namespaces/{namespace-id}/collections/{collection-id}: - get: - tags: - - namespaces - summary: search for documents in {collection-id} - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/collection-id" - - $ref: "#/components/parameters/where" - - $ref: "#/components/parameters/fields" - - $ref: "#/components/parameters/page-size" - - $ref: "#/components/parameters/page-state" - - $ref: "#/components/parameters/sort" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "count": 1, - "pageState": "2f4acd34", - "data": - [ - { - "documentId": "my-first-post-a6h54", - "title": "Hello World", - "author": { "name": "Cliff Wicklow" }, - }, - ], - } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - post: - tags: - - namespaces - summary: add a new document to {collection-id} - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/collection-id" - requestBody: - description: document - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: - { - "title": "Hello World", - "author": - { - "name": "CRW", - "social": - { "foo-bar-789": { "followers": 1, "likes": 7 } }, - }, - } - responses: - 201: - description: resource created - content: - application/json: - examples: - default: - value: - { "documentId": "e73c77ec-002d-457a-8b65-8ce7cfb15fc7" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 409: - $ref: "#/components/responses/409" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/namespaces/{namespace-id}/collections/{collection-id}/{document-id}: - get: - tags: - - namespaces - summary: get a document by id - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/collection-id" - - $ref: "#/components/parameters/document-id" - - $ref: "#/components/parameters/fields" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "data": - { - "documentId": "my-first-post-a6h54", - "title": "Hello World", - "author": { "name": "Cliff Wicklow" }, - }, - } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 404: - $ref: "#/components/responses/404" - 500: - $ref: "#/components/responses/500" - put: - tags: - - namespaces - summary: replace a document - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/collection-id" - - $ref: "#/components/parameters/document-id" - requestBody: - description: document - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: { "title": "Hello World", "author": { "name": "DKG" } } - responses: - 200: - description: resource updated - content: - application/json: - examples: - default: - value: - { "documentId": "e73c77ec-002d-457a-8b65-8ce7cfb15fc7" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - patch: - tags: - - namespaces - summary: update part of a document - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/collection-id" - - $ref: "#/components/parameters/document-id" - requestBody: - description: document - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: { "title": "Hello World" } - responses: - 200: - description: resource updated - content: - application/json: - examples: - default: - value: - { "documentId": "e73c77ec-002d-457a-8b65-8ce7cfb15fc7" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 404: - $ref: "#/components/responses/404" - 500: - $ref: "#/components/responses/500" - delete: - tags: - - namespaces - summary: delete a document - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/collection-id" - - $ref: "#/components/parameters/document-id" - responses: - 204: - description: resource deleted - content: - application/json: - examples: - default: - value: { } - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/namespaces/{namespace-id}/collections/{collection-id}/{document-id}/{document-path}: - get: - tags: - - namespaces - summary: get a sub document by path - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/collection-id" - - $ref: "#/components/parameters/document-id" - - $ref: "#/components/parameters/document-path" - - $ref: "#/components/parameters/fields" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "documentPath": "author", - "data": { "name": "Cliff Wicklow" }, - } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 404: - $ref: "#/components/responses/404" - 500: - $ref: "#/components/responses/500" - put: - tags: - - namespaces - summary: replace a sub document - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/collection-id" - - $ref: "#/components/parameters/document-id" - - $ref: "#/components/parameters/document-path" - requestBody: - description: document - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: { "foo-bar-789": { "followers": 1, "likes": 7 } } - - responses: - 201: - description: resource created - content: - application/json: - examples: - default: - value: - { "documentId": "e73c77ec-002d-457a-8b65-8ce7cfb15fc7" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - patch: - tags: - - namespaces - summary: update part of a sub document - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/collection-id" - - $ref: "#/components/parameters/document-id" - - $ref: "#/components/parameters/document-path" - requestBody: - description: document - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: { "title": "Hello World" } - responses: - 200: - description: resource updated - content: - application/json: - examples: - default: - value: - { "documentId": "e73c77ec-002d-457a-8b65-8ce7cfb15fc7" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 404: - $ref: "#/components/responses/404" - 500: - $ref: "#/components/responses/500" - delete: - tags: - - namespaces - summary: delete a sub document - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/collection-id" - - $ref: "#/components/parameters/document-id" - - $ref: "#/components/parameters/document-path" - responses: - 204: - description: resource deleted - content: - application/json: - examples: - default: - value: { } - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/keyspaces/{keyspace-id}/{table-id}: - get: - tags: - - keyspaces - summary: search a table - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - - $ref: "#/components/parameters/where" - - $ref: "#/components/parameters/fields" - - $ref: "#/components/parameters/page-size" - - $ref: "#/components/parameters/page-state" - - $ref: "#/components/parameters/sort" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "count": 1, - "pageState": "2f4acd34", - "data": - [ { "title": "Hello World", "author": "Cliff Wicklow" } ], - } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - post: - tags: - - keyspaces - summary: add a new row - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - requestBody: - description: row - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: - { - "pk": "e73c77ec-002d-457a-8b65-8ce7cfb15fc7", - "title": "Hello World", - "author": "CRW", - } - responses: - 201: - description: resource created - content: - application/json: - examples: - default: - value: { "pk": "e73c77ec-002d-457a-8b65-8ce7cfb15fc7" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 409: - $ref: "#/components/responses/409" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/keyspaces/{keyspace-id}/{table-id}/{primary-key}: - get: - tags: - - keyspaces - summary: get a row(s) - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - - $ref: "#/components/parameters/primary-key" - - $ref: "#/components/parameters/fields" - - $ref: "#/components/parameters/page-size" - - $ref: "#/components/parameters/page-state" - - $ref: "#/components/parameters/sort" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "count": 1, - "pageState": "2f4acd34", - "data": - [ { "title": "Hello World", "author": "Cliff Wicklow" } ], - } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - put: - tags: - - keyspaces - summary: replace a row(s) - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - - $ref: "#/components/parameters/primary-key" - - $ref: "#/components/parameters/raw" - requestBody: - description: document - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: { "title": "New Title" } - responses: - 200: - description: resource updated - content: - application/json: - examples: - default: - value: - { "rowsModified": 208, "data": { "title": "New Title" } } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - patch: - tags: - - keyspaces - summary: update part of a row(s) - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - - $ref: "#/components/parameters/primary-key" - - $ref: "#/components/parameters/raw" - requestBody: - description: document - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: { "title": "New Title", "author": null } - responses: - 200: - description: resource updated - content: - application/json: - examples: - default: - value: - { "rowsModified": 208, "data": { "title": "New Title" } } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - delete: - tags: - - keyspaces - summary: delete a row(s) - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - - $ref: "#/components/parameters/primary-key" - responses: - 204: - description: resource deleted - content: - application/json: - examples: - default: - value: { } - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/schemas/keyspaces: - get: - tags: - - schemas - summary: list keyspaces - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "data": - [ - { - "name": "killrvideo", - "datacenters": - [ - { "name": "dc1", "replicas": 3 }, - { "name": "dc2", "replicas": 3 }, - ], - }, - ], - } - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - post: - tags: - - schemas - summary: create a keyspace - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - requestBody: - description: "" - required: true - content: - application/json: - schema: - type: object - examples: - simple strategy: - value: { "name": "killrvideo" } - datacenters: - value: - { - "name": "killrvideo", - "datacenters": - [ - { "name": "dc1", "replicas": 3 }, - { "name": "dc2", "replicas": 3 }, - ], - } - responses: - 201: - description: resource created - content: - application/json: - examples: - default: - value: { "name": "killrvideo" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 409: - $ref: "#/components/responses/409" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/schemas/keyspaces/{keyspace-id}: - get: - tags: - - schemas - summary: get a keyspace - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "data": - { - "name": "killrvideo", - "datacenters": - [ - { "name": "dc1", "replicas": 3 }, - { "name": "dc2", "replicas": 3 }, - ], - }, - } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 404: - $ref: "#/components/responses/404" - 500: - $ref: "#/components/responses/500" - delete: - tags: - - schemas - summary: delete a keyspace - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - responses: - 204: - description: resource deleted - content: - application/json: - examples: - default: - value: { } - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/schemas/keyspaces/{keyspace-id}/tables: - get: - tags: - - schemas - summary: list tables - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "data": - [ - { - "name": "string", - "keyspace": "string", - "columnDefinitions": - [ - { - "name": "emailaddress", - "typeDefinition": "text", - "static": false, - }, - ], - "primaryKey": - { - "partitionKey": [ "string" ], - "clusteringKey": [ "string" ], - }, - "tableOptions": - { - "defaultTimeToLive": 0, - "clusteringExpression": - [ { "column": "string", "order": "ASC" } ], - }, - }, - ], - } - 401: - $ref: "#/components/responses/401" - 404: - $ref: "#/components/responses/404" - 500: - $ref: "#/components/responses/500" - post: - tags: - - schemas - summary: create a table - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - requestBody: - description: "" - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: - { - "name": "users", - "ifNotExists": false, - "columnDefinitions": - [ - { - "name": "emailaddress", - "typeDefinition": "text", - "static": false, - }, - ], - "primaryKey": - { - "partitionKey": [ "string" ], - "clusteringKey": [ "string" ], - }, - "tableOptions": - { - "defaultTimeToLive": 0, - "clusteringExpression": - [ { "column": "string", "order": "ASC" } ], - }, - } - responses: - 201: - description: resource created - content: - application/json: - examples: - default: - value: { "name": "users" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 409: - $ref: "#/components/responses/409" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/schemas/keyspaces/{keyspace-id}/tables/{table-id}: - get: - tags: - - schemas - summary: get a table - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "data": - { - "name": "string", - "keyspace": "string", - "columnDefinitions": - [ - { - "name": "emailaddress", - "typeDefinition": "text", - "static": false, - }, - ], - "primaryKey": - { - "partitionKey": [ "string" ], - "clusteringKey": [ "string" ], - }, - "tableOptions": - { - "defaultTimeToLive": 0, - "clusteringExpression": - [ { "column": "string", "order": "ASC" } ], - }, - }, - } - 401: - $ref: "#/components/responses/401" - 404: - $ref: "#/components/responses/404" - 500: - $ref: "#/components/responses/500" - put: - tags: - - schemas - summary: replace a table definition, except for columns - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - requestBody: - description: "" - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: - { - "name": "users", - "ifNotExists": false, - "primaryKey": - { - "partitionKey": [ "string" ], - "clusteringKey": [ "string" ], - }, - "tableOptions": - { - "defaultTimeToLive": 0, - "clusteringExpression": - [ { "column": "string", "order": "ASC" } ], - }, - } - responses: - 200: - description: resource updated - content: - application/json: - examples: - default: - value: { "name": "users" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 404: - $ref: "#/components/responses/404" - 409: - $ref: "#/components/responses/409" - 500: - $ref: "#/components/responses/500" - delete: - tags: - - schemas - summary: delete a table - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - responses: - 204: - description: resource deleted - content: - application/json: - examples: - default: - value: { } - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/schemas/keyspaces/{keyspace-id}/tables/{table-id}/columns: - get: - tags: - - schemas - summary: list columns - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "data": - [ - { - "name": "emailaddress", - "typeDefinition": "text", - "static": false, - }, - ], - } - 401: - $ref: "#/components/responses/401" - 404: - $ref: "#/components/responses/404" - 500: - $ref: "#/components/responses/500" - post: - tags: - - schemas - summary: create a column - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - requestBody: - description: "" - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: - { - "name": "emailaddress", - "typeDefinition": "text", - "static": false, - } - responses: - 201: - description: resource created - content: - application/json: - examples: - default: - value: { "name": "emailaddress" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 409: - $ref: "#/components/responses/409" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/schemas/keyspaces/{keyspace-id}/tables/{table-id}/columns/{column-id}: - get: - tags: - - schemas - summary: get a column - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - - $ref: "#/components/parameters/column-id" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "data": - { - "name": "emailaddress", - "typeDefinition": "text", - "static": false, - }, - } - 401: - $ref: "#/components/responses/401" - 404: - $ref: "#/components/responses/404" - 500: - $ref: "#/components/responses/500" - put: - tags: - - schemas - summary: replace a column definition - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - - $ref: "#/components/parameters/column-id" - requestBody: - description: "" - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: - { - "name": "emailaddressRenamed", - "typeDefinition": "text", - "static": true, - } - responses: - 200: - description: resource updated - content: - application/json: - examples: - default: - value: { "name": "users" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 404: - $ref: "#/components/responses/404" - 409: - $ref: "#/components/responses/409" - 500: - $ref: "#/components/responses/500" - delete: - tags: - - schemas - summary: delete a column - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/keyspace-id" - - $ref: "#/components/parameters/table-id" - - $ref: "#/components/parameters/column-id" - responses: - 204: - description: resource deleted - content: - application/json: - examples: - default: - value: { } - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/schemas/namespaces: - get: - tags: - - schemas - summary: list namespaces - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "data": - [ - { - "name": "killrvideo", - "datacenters": - [ - { "name": "dc1", "replicas": 3 }, - { "name": "dc2", "replicas": 3 }, - ], - }, - ], - } - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - post: - tags: - - schemas - summary: create a namespace - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - requestBody: - description: "" - required: true - content: - application/json: - schema: - type: object - examples: - simple strategy: - value: { "name": "killrvideo" } - datacenters: - value: - { - "name": "killrvideo", - "datacenters": - [ - { "name": "dc1", "replicas": 3 }, - { "name": "dc2", "replicas": 3 }, - ], - } - responses: - 201: - description: resource created - content: - application/json: - examples: - default: - value: { "name": "killrvideo" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 409: - $ref: "#/components/responses/409" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/schemas/namespaces/{namespace-id}: - get: - tags: - - schemas - summary: get a namespace - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "data": - { - "name": "killrvideo", - "datacenters": - [ - { "name": "dc1", "replicas": 3 }, - { "name": "dc2", "replicas": 3 }, - ], - }, - } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 404: - $ref: "#/components/responses/404" - 500: - $ref: "#/components/responses/500" - delete: - tags: - - schemas - summary: delete a namespace - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - responses: - 204: - description: resource deleted - content: - application/json: - examples: - default: - value: { } - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/schemas/namespaces/{namespace-id}/collections: - get: - tags: - - schemas - summary: list collections in a namespace - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "data": - [ - { - "name": "users", - "fields": - { "name": { "type": "String", "index": true } }, - "validationAction": "warn", - }, - ], - } - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - post: - tags: - - schemas - summary: create a collection - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - requestBody: - description: "" - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: - { - "name": "users", - "fields": { "name": { "type": "String", "index": true } }, - "validationAction": "warn", - } - responses: - 201: - description: resource created - content: - application/json: - examples: - default: - value: { "name": "killrvideo" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 409: - $ref: "#/components/responses/409" - 500: - $ref: "#/components/responses/500" - /api/rest/v2/schemas/namespaces/{namespace-id}/collections/{collection-id}: - get: - tags: - - schemas - summary: get a collection - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/collection-id" - - $ref: "#/components/parameters/raw" - responses: - 200: - description: "" - content: - application/json: - examples: - default: - value: - { - "data": - [ - { - "name": "users", - "fields": - { "name": { "type": "String", "index": true } }, - "validationAction": "warn", - }, - ], - } - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" - put: - tags: - - schemas - summary: update (replace) a collection - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/collection-id" - requestBody: - description: "" - required: true - content: - application/json: - schema: - type: object - examples: - default: - value: - { - "name": "users", - "fields": { "name": { "type": "String", "index": true } }, - "validationAction": "warn", - } - responses: - 200: - description: resource updated - content: - application/json: - examples: - default: - value: { "name": "users" } - 400: - $ref: "#/components/responses/400" - 401: - $ref: "#/components/responses/401" - 409: - $ref: "#/components/responses/409" - 500: - $ref: "#/components/responses/500" - delete: - tags: - - schemas - summary: delete a collection - parameters: - - $ref: "#/components/parameters/X-Cassandra-Request-Id" - - $ref: "#/components/parameters/databaseId" - - $ref: "#/components/parameters/region" - - $ref: "#/components/parameters/pretty" - - $ref: "#/components/parameters/X-Cassandra-Token" - - $ref: "#/components/parameters/namespace-id" - - $ref: "#/components/parameters/collection-id" - responses: - 204: - description: resource deleted - content: - application/json: - examples: - default: - value: { } - 401: - $ref: "#/components/responses/401" - 500: - $ref: "#/components/responses/500" -components: - parameters: - region: - name: "region" - description: "Cloud region where your database lives.
For example, `us-east-1`" - in: "path" - schema: - type: "string" - required: true - databaseId: - name: "databaseId" - description: "UUID of your database from the Astra URL.
For example, `d341f349-e5db-46d2-9c90-bb9ebaa6f0fc`." - in: "path" - schema: - type: "string" - required: true - X-Cassandra-Token: - name: X-Cassandra-Token - in: header - required: true - description: "The token returned from the authorization endpoint. Use this token in each request to the database." - schema: - type: string - X-Cassandra-Request-Id: - name: X-Cassandra-Request-Id - in: header - required: true - description: "Unique identifier (UUID) for the request. Use any valid UUID." - schema: - type: string - format: uuid - pretty: - name: pretty - in: query - description: format results - schema: - type: boolean - raw: - name: raw - in: query - description: unwrap results - schema: - type: boolean - namespace-id: - name: namespace-id - in: path - description: namespace name - required: true - schema: - type: string - collection-id: - name: collection-id - in: path - description: name of the document collection - required: true - schema: - type: string - document-id: - name: document-id - in: path - description: the id of the document - required: true - schema: - type: string - document-path: - name: document-path - in: path - description: a JSON path - required: true - schema: - type: string - keyspace-id: - name: keyspace-id - in: path - description: keyspace name - required: true - schema: - type: string - table-id: - name: table-id - in: path - description: table name - required: true - schema: - type: string - column-id: - name: column-id - in: path - description: column name - required: true - schema: - type: string - primary-key: - name: primary-key - in: path - required: true - description: | - Value from the primary key column for the table. Define composite keys by separating values with - slashes (`val1/val2...`) in the order they were defined.
For example, if the composite key - was defined as `PRIMARY KEY(race_year, race_name)` then the primary key in the path would be - `race_year/race_name` - schema: - type: string - fields: - name: fields - in: query - description: URL escaped, comma delimited list of keys to include - schema: - type: string - examples: - default: - value: "name, email" - sort: - name: sort - in: query - description: keys to sort by - schema: - type: object - examples: - default: - value: { "documentId": "asc", "name": "desc" } - page-state: - name: page-state - in: query - description: move the cursor to a particular result - schema: - type: string - examples: - default: - value: "" - page-size: - name: page-size - description: restrict the number of returned items (max 100) - in: query - schema: - type: integer - format: int32 - examples: - default: - value: 10 - where: - name: where - in: query - description: | - URL escaped JSON query using the following keys: - | Key | Operation | - |-|-| - | $lt | Less Than | - | $lte | Less Than Or Equal To | - | $gt | Greater Than | - | $gte | Greater Than Or Equal To | - | $ne | Not Equal To | - | $in | Contained In | - | $exists | A value is set for the key | - | $select | This matches a value for a key in the result of a different query | - | $dontSelect | Requires that a key’s value not match a value for a key in the result of a different query | - | $all | Contains all of the given values | - | $regex | Requires that a key’s value match a regular expression | - | $text | Performs a full text search on indexed fields | - schema: - type: object - examples: - search with or: - value: - { - "author.name": "Cliff Wicklow", - "createTime": { "$gte": 0 }, - "$or": - [ { "name": "Cliff" }, { "documentId": "my-first-post-a6h54" } ], - } - examples: { } - responses: - 404: - description: Not Found - content: - application/json: - examples: - default: - value: { "code": 404, "description": "Not Found" } - 400: - description: Invalid input - content: - application/json: - examples: - default: - value: { "code": 400, "description": "Invalid input" } - 401: - description: Unauthorized - content: - application/json: - examples: - default: - value: { "code": 401, "description": "Unauthorized" } - 409: - description: Conflict - content: - application/json: - examples: - default: - value: { "code": 409, "description": "resource already exists." } - 500: - description: Internal server error - content: - application/json: - examples: - default: - value: { "code": 500, "description": "Internal server error" } - schemas: - Credentials: - type: object - required: - - username - - password - description: User credentials for authenticating - properties: - username: - type: string - description: Username - password: - type: string - description: Password diff --git a/engine-rest/src/test/java/io/nosqlbench/engine/rest/services/openapi/OpenApiLoaderTest.java b/engine-rest/src/test/java/io/nosqlbench/engine/rest/services/openapi/OpenApiLoaderTest.java deleted file mode 100644 index e4a2a30f1..000000000 --- a/engine-rest/src/test/java/io/nosqlbench/engine/rest/services/openapi/OpenApiLoaderTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022 nosqlbench - * - * 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 io.nosqlbench.engine.rest.services.openapi; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.junit.jupiter.api.Test; - -public class OpenApiLoaderTest { - private final static Logger logger = LogManager.getLogger(OpenApiLoaderTest.class); - @Test - public void testYamlGenerator() { - String openidpath = "stargate.yaml"; - String filterJson = "{\n" + - "'POST /api/rest/v1/auth' : {}\n" + - "}\n"; - - String result = OpenApiLoader.generateWorkloadFromFilepath(openidpath, filterJson); - logger.debug(result); - - } - -} diff --git a/engine-rest/src/test/resources/log4j2-test.xml b/engine-rest/src/test/resources/log4j2-test.xml deleted file mode 100644 index dc9a74051..000000000 --- a/engine-rest/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - %d %p %C{1.} [%t] %m%n - - - - - - - - - - - - - - - - - diff --git a/mvn-defaults/pom.xml b/mvn-defaults/pom.xml index 6e1a1d2ac..15760b25a 100644 --- a/mvn-defaults/pom.xml +++ b/mvn-defaults/pom.xml @@ -70,7 +70,6 @@ - org.testcontainers testcontainers-bom @@ -78,25 +77,21 @@ pom import - org.codehaus.groovy groovy - 3.0.14 + 3.0.17 - org.snakeyaml snakeyaml-engine 2.6 - info.picocli picocli 4.7.4 - net.java.dev.jna @@ -108,44 +103,37 @@ jna-platform 5.13.0 - org.junit.jupiter 5.9.0-M1 junit-jupiter test - org.mpierce.metrics.reservoir hdrhistogram-metrics-reservoir 1.1.3 - org.hdrhistogram HdrHistogram 2.1.12 - io.dropwizard.metrics metrics-graphite 4.2.19 - io.dropwizard.metrics metrics-core 4.2.19 - org.apache.commons commons-text 1.10.0 - org.apache.commons commons-math4-core @@ -171,7 +159,6 @@ commons-statistics-distribution 1.0 - org.openjdk.jmh jmh-core @@ -182,53 +169,65 @@ jmh-generator-annprocess 1.36 - com.mitchtalmadge ascii-data 1.4.0 - org.lz4 lz4-java 1.4.1 - org.xerial.snappy snappy-java 1.1.10.1 - + + com.datastax.oss + java-driver-query-builder + 4.16.0 + + + org.snakeyaml + snakeyaml-engine + 2.6 + + + org.xerial.snappy + snappy-java + 1.1.10.1 + + + com.esri.geometry + esri-geometry-api + 2.2.4 + io.netty netty-handler 4.1.94.Final - io.netty netty-transport-native-epoll 4.1.51.Final linux-x86_64 - io.netty netty-transport-native-kqueue 4.1.46.Final linux-x86_64 - io.netty netty-codec-haproxy 4.1.86.Final - com.github.docker-java docker-java-api @@ -240,11 +239,45 @@ - + + org.apache.commons + commons-collections4 + 4.4 + + + org.bouncycastle + bcprov-jdk15on + 1.69 + + + com.fasterxml.jackson.core + jackson-databind + 2.15.2 + + + commons-io + commons-io + 2.11.0 + + + org.apache.tinkerpop + gremlin-core + 3.6.4 + + + com.datastax.oss + java-driver-core + 4.16.0 + + + org.apache.tinkerpop + tinkergraph-gremlin + 3.6.4 + com.github.docker-java docker-java-core - 3.3.0 + 3.3.2 org.slf4j @@ -252,13 +285,11 @@ - com.squareup.okhttp3 okhttp 4.10.0 - com.github.docker-java docker-java-transport-okhttp @@ -269,9 +300,7 @@ jcl-over-slf4j - - com.github.docker-java docker-java @@ -284,55 +313,46 @@ - com.github.oshi oshi-core-java11 6.4.3 - com.google.code.gson gson 2.10.1 - com.amazonaws aws-java-sdk-s3 1.12.495 - com.elega9t number-to-words 1.0.0 - org.greenrobot essentials 3.1.0 - org.apache.commons commons-lang3 3.12.0 - com.squareup javapoet 1.13.0 - joda-time joda-time 2.12.5 - org.apache.commons commons-csv @@ -348,37 +368,31 @@ mvel2 2.5.0.Final - org.antlr antlr4-runtime 4.12.0 - org.apache.commons commons-compress 1.21 - com.fasterxml.jackson.jaxrs jackson-jaxrs-json-provider 2.9.8 - com.sun.xml.bind jaxb-core 2.3.0.1 - com.sun.xml.bind jaxb-impl 2.4.0-b180830.0438 - org.graalvm.sdk diff --git a/virtdata-api/pom.xml b/virtdata-api/pom.xml index ffb5f45ea..ca9c21787 100644 --- a/virtdata-api/pom.xml +++ b/virtdata-api/pom.xml @@ -43,24 +43,19 @@ ${revision} nb-api - io.nosqlbench virtdata-lang ${revision} - - org.apache.commons commons-lang3 - com.squareup javapoet - org.apache.commons commons-math4-core @@ -76,7 +71,6 @@ org.apache.commons commons-math4-legacy-exception - 4.0-beta1 org.apache.commons @@ -85,9 +79,16 @@ com.datastax.oss java-driver-core - 4.16.0 compile + + com.github.docker-java + docker-java-core + + + com.fasterxml.jackson.core + jackson-databind +