You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/10/07 23:35:13 UTC

[GitHub] [cassandra-sidecar] frankgh opened a new pull request, #37: CASSANDRASC-43 Add Schema API

frankgh opened a new pull request, #37:
URL: https://github.com/apache/cassandra-sidecar/pull/37

   This commit introduces the Schema API. Two new endpoints are added:
   
   - /api/v1/schema/keyspaces This endpoint returns the SchemaResponse with the full schema for all keyspaces.
   
   - /api/v1/schema/keyspaces/:keyspace This endpoint returns the SchemaResponse with the full schema for the requested keyspace.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra-sidecar] yifan-c commented on a diff in pull request #37: CASSANDRASC-43 Add Schema API

Posted by GitBox <gi...@apache.org>.
yifan-c commented on code in PR #37:
URL: https://github.com/apache/cassandra-sidecar/pull/37#discussion_r990556195


##########
src/test/resources/schema/test_keyspace_schema.cql:
##########
@@ -0,0 +1,56 @@
+CREATE KEYSPACE testkeyspace WITH REPLICATION = { 'class' : 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '1' } AND DURABLE_WRITES = true;
+
+CREATE TYPE testkeyspace.cidr_range (
+    id uuid,
+    start inet,
+    end inet,
+    description text
+);
+
+CREATE TABLE testkeyspace.testtable (
+                                        partition_key_1 uuid,

Review Comment:
   nit: can be nicely indented the same as `CREATE TYPE`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra-sidecar] dineshjoshi commented on a diff in pull request #37: CASSANDRASC-43 Add Schema API

Posted by GitBox <gi...@apache.org>.
dineshjoshi commented on code in PR #37:
URL: https://github.com/apache/cassandra-sidecar/pull/37#discussion_r997515355


##########
common/src/main/java/org/apache/cassandra/sidecar/common/data/SchemaResponse.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.cassandra.sidecar.common.data;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * A class representing a response for the {@link SchemaRequest}.
+ */
+public class SchemaResponse
+{
+    private final String keyspace;
+    private final String schema;
+
+    /**
+     * Constructs a {@link SchemaResponse} object with the given {@code schema}.
+     *
+     * @param schema the schema for all keyspaces
+     */
+    public SchemaResponse(String schema)
+    {
+        this.keyspace = null;
+        this.schema = Objects.requireNonNull(schema, "schema must be non-null");
+    }
+
+    /**
+     * Constructs a {@link SchemaResponse} object with the {@code schema} for the given {@code keyspace}.
+     *
+     * @param keyspace the keyspace in Cassandra
+     * @param schema   the schema for the given {@code keyspace}
+     */
+    public SchemaResponse(String keyspace, String schema)
+    {
+        this.keyspace = Objects.requireNonNull(keyspace, "keyspace must be non-null");
+        this.schema = Objects.requireNonNull(schema, "schema must be non-null");
+    }
+
+    /**
+     * @return the name of the Cassandra keyspace
+     */
+    @JsonInclude(JsonInclude.Include.NON_NULL)
+    public String getKeyspace()

Review Comment:
   `getKeyspace()` -> `keyspace()`



##########
common/src/main/java/org/apache/cassandra/sidecar/common/data/SchemaRequest.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.cassandra.sidecar.common.data;
+
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Holder class for the {@link org.apache.cassandra.sidecar.routes.SchemaHandler}
+ * request parameters
+ */
+public class SchemaRequest extends QualifiedTableName
+{
+    /**
+     * Constructs a {@link SchemaRequest} with the {@link org.jetbrains.annotations.Nullable} {@code keyspace}.
+     *
+     * @param keyspace the keyspace in Cassandra
+     */
+    public SchemaRequest(@Nullable String keyspace)
+    {
+        super(keyspace, null, false);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString()
+    {
+        return "SchemaRequest{" +
+               "keyspace='" + getKeyspace() + '\'' +

Review Comment:
   Please drop the get before the getters...



##########
common/src/main/java/org/apache/cassandra/sidecar/common/data/SchemaResponse.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.cassandra.sidecar.common.data;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * A class representing a response for the {@link SchemaRequest}.
+ */
+public class SchemaResponse
+{
+    private final String keyspace;
+    private final String schema;
+
+    /**
+     * Constructs a {@link SchemaResponse} object with the given {@code schema}.
+     *
+     * @param schema the schema for all keyspaces
+     */
+    public SchemaResponse(String schema)
+    {
+        this.keyspace = null;
+        this.schema = Objects.requireNonNull(schema, "schema must be non-null");
+    }
+
+    /**
+     * Constructs a {@link SchemaResponse} object with the {@code schema} for the given {@code keyspace}.
+     *
+     * @param keyspace the keyspace in Cassandra
+     * @param schema   the schema for the given {@code keyspace}
+     */
+    public SchemaResponse(String keyspace, String schema)
+    {
+        this.keyspace = Objects.requireNonNull(keyspace, "keyspace must be non-null");
+        this.schema = Objects.requireNonNull(schema, "schema must be non-null");
+    }
+
+    /**
+     * @return the name of the Cassandra keyspace
+     */
+    @JsonInclude(JsonInclude.Include.NON_NULL)
+    public String getKeyspace()
+    {
+        return keyspace;
+    }
+
+    /**
+     * @return the string representing the schema for the response
+     */
+    public String getSchema()

Review Comment:
   `getSchema()` -> `schema()`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra-sidecar] frankgh commented on pull request #37: CASSANDRASC-43 Add Schema API

Posted by GitBox <gi...@apache.org>.
frankgh commented on PR #37:
URL: https://github.com/apache/cassandra-sidecar/pull/37#issuecomment-1281626981

   Closed via https://github.com/apache/cassandra-sidecar/commit/6e358acfce071cad16ac88c15dc2229bbb8a7944


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra-sidecar] frankgh closed pull request #37: CASSANDRASC-43 Add Schema API

Posted by GitBox <gi...@apache.org>.
frankgh closed pull request #37: CASSANDRASC-43 Add Schema API
URL: https://github.com/apache/cassandra-sidecar/pull/37


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org