Manage keyspaces and tables
Perform limited schema management operations:
-
Get information about one or all keyspaces
-
Edit a keyspace’s configuration
-
Drop a keyspace
-
Truncate a table
-
Drop a table
GET /{cluster_id}/keyspaces
Retrieve all configured keyspaces in the cluster.
Path arguments: * cluster_id: The ID of a cluster returned from GET /cluster-configs.
Query parameters:
-
ksfields: Optional comma-delimited list of explicit keyspace properties to return.
-
cffields: Optional comma-delimited list of explicit table properties to return.
Returns a dictionary where the key is the keyspace name, and the value is a dictionary of its properties. The list of properties for keyspaces and tables depends on the version of DataStax Enterprise (DSE) that you’re running.
Example:
curl http://127.0.0.1:8888/Test_Cluster/keyspaces
Output:
{
"Keyspace1": {
"strategy_options": {
"replication_factor": 1
},
"column_families": {
"SuperCounter1": {
"is_in_memory": false,
"create_query": "CREATE TABLE \"Keyspace1\".\"SuperCounter1\" (\key blob, ...)",
"solr_core": false
},
...
}
"durable_writes": true,
"replica_placement_strategy": "org.apache.cassandra.locator.SimpleStrategy",
"is_system": false
},
...
}
GET /{cluster_id}/keyspaces/{ks_name}
Retrieve information about a specific keyspace in the cluster.
Path arguments:
-
cluster_id: The ID of a cluster returned from GET /cluster-configs.
-
ks_name: The value of a
keyspaceproperty in the output of GET /{cluster_id}/keyspaces. -
ksfields: Comma-delimited list of explicit keyspace properties to return.
-
cffields: Comma-delimited list of explicit table properties to return.
Returns the dictionary containing all keyspace properties. The properties returned depend on the version of DSE.
Example:
curl http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace1
Output:
{
"strategy_options": {
"replication_factor": 1
},
"column_families": {
"SuperCounter1": {
"is_in_memory": false,
"create_query": "CREATE TABLE \"Keyspace1\".\"SuperCounter1\" (\key blob, ...)",
"solr_core": false
},
...
}
"durable_writes": true,
"replica_placement_strategy": "org.apache.cassandra.locator.SimpleStrategy",
"is_system": false
}
PUT /{cluster_id}/keyspaces/{ks_name}
Update a keyspace.
Path arguments:
-
cluster_id: The ID of a cluster returned from GET /cluster-configs.
-
ks_name: The name of the 'keyspace' to update.
Body: A JSON dictionary of all keyspace attributes.
|
The request body is a desired state definition that must include all keyspace attributes. Omitted attributes are reset to default values or cause the operation to fail. |
The JSON body should be similar to the one used when creating a keyspace.
Example:
curl -X PUT
http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace1
-d '{
"strategy_class": "org.apache.cassandra.locator.SimpleStrategy",
"strategy_options": {"replication_factor": "2"},
"durable_writes": true
}'
DELETE /{cluster_id}/keyspaces/{ks_name}
Drop a keyspace from the cluster.
Path arguments:
-
cluster_id: The ID of a cluster returned from GET /cluster-configs.
-
ks_name: The name of the
keyspaceto delete.
Returns 204 response code if the keyspace was deleted successfully.
Example:
curl -X DELETE http://127.0.0.1:8888/Test_Cluster/keyspaces/test_ks
DELETE /{cluster_id}/data/{ks_name}/{cf_name}
Truncate a table. Deletes all data from the table but does not delete the table itself.
Path arguments:
-
cluster_id: The ID of a cluster returned from GET /cluster-configs.
-
ks_name: The name of the
keyspacecontaining the table. -
cf_name: The name of the table to truncate.
Returns 204 response code and a null message if the table was truncated successfully.
Example:
curl -X DELETE http://127.0.0.1:8888/Test_Cluster/data/test_ks/users
DELETE /{cluster_id}/keyspaces/{ks_name}/cf/{cf_name}
Drop a table.
Path arguments:
-
cluster_id: The ID of a cluster returned from GET /cluster-configs.
-
ks_name: The name of the
keyspacecontaining the table. -
cf_name: The name of the table to delete.
Returns 204 response code if the table was deleted successfully.
Example:
curl -X DELETE http://127.0.0.1:8888/Test_Cluster/keyspaces/test_ks/cf/users