You can perform keyspace and column family operations, such as adding and getting information about keyspaces and column families, using these HTTP methods:
| Keyspace and Column Family Management Methods | URL |
|---|---|
| Retrieve a list of all keyspaces. | GET /{cluster_id}/keyspaces |
| Retrieve information about a keyspace. | GET /{cluster_id}/keyspaces/{ks_name} |
| Retrieve a single property about a keyspace | GET /{cluster_id}/keyspaces/{ks_name}/{attribute} |
| Add a keyspace to the cluster. | POST /{cluster_id}/keyspaces/{ks_name} |
| Add a column family to a keyspace. | POST /{cluster_id}/keyspaces/{ks_name}/cf/{cf_name} |
| Get the description of a column family. | GET /{cluster_id}/keyspaces/{ks_name}/cf/{cf_name} |
| Truncate a column family. | DELETE /{cluster_id}/data/{ks_name}/{cf_name} |
| Delete a column family itself. | DELETE /{cluster_id}/keyspaces/{ks_name}/cf/{cf_name} |
| Delete a keyspace in a cluster. | DELETE /{cluster_id}/keyspaces/{ks_name} |
Retrieve all configured keyspaces in the cluster.
| Path arguments: | cluster_id -- A key, which identifies the node's cluster, in the dictionary returned by GET /cluster-configs. |
|---|---|
| Query params: |
|
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
-X GET
Output:
{
"Keyspace1": {
"column_families": {
"ColFam1": {
"column_type": "Standard",
"min_compaction_threshold": 4,
...
},
...
},
"replica_placement_strategy": "org.apache.cassandra.locator.SimpleStrategy",
"strategy_options": {
"replication_factor": "1"
},
...
},
...
}
Retrieve information about a specific keyspace in the cluster.
| Path arguments: |
|
|---|---|
| Query params: |
|
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
-X GET
Output:
{
"column_families": {
"ColFam1": {
"column_type": "Standard",
"min_compaction_threshold": 4,
...
},
...
},
"replica_placement_strategy": "org.apache.cassandra.locator.SimpleStrategy",
"strategy_options": {
"replication_factor": "1"
},
...
}
Retrieve a single property of a keyspace.
| Path arguments: |
|
|---|
Example
curl
http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace1/replica_placement_strategy
-X GET
Output:
"org.apache.cassandra.locator.SimpleStrategy"
Add a keyspace to the cluster.
| Path arguments: |
|
|---|---|
| Body : | A json dictionary describing the attributes of the keyspace you are adding. |
| Responses: | 200 -- Keyspace created successfully |
The CQL keyspace storage parameters have keys corresponding to Cassandra keys in the keyspace dictionary and are valid attributes for strategy_class and strategy_options parameters:
| Keyspace Storage Parameter | Keyspace Dictionary Key |
|---|---|
| strategy_class | replica_placement_strategy |
| strategy_options | strategy_options |
Example
curl
http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace2
-X POST
-d
'{"strategy_class": "org.apache.cassandra.locator.SimpleStrategy",
"strategy_options": {"replication_factor": "1"}
}'
Add a column family to a keyspace.
| Path arguments: |
|
|---|---|
| Body : | A json dictionary describing the attributes of the column family. Keys in the dictionary are valid column family attributes, such as column_type and comparator_type, in Cassandra. |
| Responses: | 200 -- Column family created successfully |
Example
curl
http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace1/cf/MyColFam
-X POST
-d
'{"column_type": "Standard",
"comment": "",
"comparator_type": "org.apache.cassandra.db.marshal.UTF8Type",
"default_validation_class": "org.apache.cassandra.db.marshal.BytesType",
"read_repair_chance": 1.0,
"row_cache_size": 0.0,
"subcomparator_type": null
}'
Get the description of a column family.
| Path arguments: |
|
|---|
Returns a dictionary describing the requested column family. Properties returned depend on the DataStax Enterprise/Cassandra version.
Example
curl
http://127.0.0.1:8888/Test_Cluster/keyspaces/test_ks/cf/users
-X GET
Output:
{
"column_type": "Standard",
"min_compaction_threshold": 4,
...
}
Truncate an existing column family. Deletes all data from the column family but does not delete the column family itself.
| Path arguments: |
|
|---|
Returns null.
Example
curl
http://127.0.0.1:8888/Test_Cluster/data/test_ks/users
-X DELETE
Delete a column family.
| Path arguments: |
|
|---|---|
| Responses: | 204 -- Column family deleted successfully |
Example
curl
http://127.0.0.1:8888/Test_Cluster/keyspaces/test_ks/cf/users
-X DELETE
Delete an existing keyspace in the cluster.
| Path arguments: |
|
|---|---|
| Responses: | 204 -- Keyspace deleted successfully |
Example
curl
http://127.0.0.1:8888/Test_Cluster/keyspaces/test_ks
-X DELETE