Managing Keyspaces and Column Families¶
You can perform keyspace and column family operations, such as adding and getting information about keyspaces and column families, using these HTTP methods:
Keyspace Management Methods | URL |
---|---|
Retrieve information about all keyspaces | GET /{cluster_id}/keyspaces |
Retrieve information about a keyspace | GET /{cluster_id}/keyspaces/{ks_name} |
Update an existing keyspace | PUT /{cluster_id}/keyspaces/{ks_name} |
Drop a keyspace in a cluster | DELETE /{cluster_id}/keyspaces/{ks_name} |
Column Family Management Methods | |
Truncate a column family | DELETE /{cluster_id}/data/{ks_name}/{cf_name} |
Drop a column family itself | DELETE /{cluster_id}/keyspaces/{ks_name}/cf/{cf_name} |
Keyspace Management Methods¶
- GET /{cluster_id}/keyspaces¶
Retrieve all configured keyspaces in the cluster.
Path arguments: cluster_id – A Cluster Config ID.
Opt. params: - ksfields – Comma delimited list of explicit keyspace properties to return.
- cffields – Comma delimited list of explicit column family 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 column families depends on the version of DataStax Enterprise/Cassandra 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 – A Cluster Config ID.
- ks_name – The value of a ‘keyspace’ property in the output of
GET /{cluster_id}/keyspaces
.
Opt. params: - ksfields – Comma delimited list of explicit keyspace properties to return.
- cffields – Comma delimited list of explicit column family properties to return.
Returns the dictionary containing all keyspace properties. The properties returned depend on the version of DataStax Enterprise/Cassandra.
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 – A Cluster Config ID.
- ks_name – The name of the keyspace to update.
Body: A JSON dictionary of all keyspace attributes, not just those you wish to change.
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 – A Cluster Config ID.
- ks_name – The name of the keyspace to delete.
Responses: 204 – Keyspace deleted successfully
Example
curl -X DELETE http://127.0.0.1:8888/Test_Cluster/keyspaces/test_ks
Column Family Management Methods¶
- DELETE /{cluster_id}/data/{ks_name}/{cf_name}¶
Truncate a column family. Deletes all data from the column family but does not delete the column family itself.
Path arguments: - cluster_id – A Cluster Config ID.
- ks_name – The name of the keyspace containing the column family.
- cf_name – The name of the column family to truncate.
Responses: 204 – Column family truncated successfully
Returns null.
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 column family.
Path arguments: - cluster_id – A Cluster Config ID.
- ks_name – The name of the keyspace containing the column family.
- cf_name – The name of the column family to delete.
Responses: 204 – Column family dropped successfully
Example
curl -X DELETE http://127.0.0.1:8888/Test_Cluster/keyspaces/test_ks/cf/users