You can perform keyspace and column family operations, such as adding and getting information about keyspaces and column families, using these HTTP methods:
Retrieve all configured keyspaces in the cluster.
| Path arguments: | cluster_id -- A Cluster Config ID. |
|---|---|
| Opt. 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
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: |
|
|---|---|
| Opt. 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
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
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: | 201 -- 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 |
| durable_writes | durable_writes |
Example
curl -X POST
http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace2
-d '{
"strategy_class": "org.apache.cassandra.locator.SimpleStrategy",
"strategy_options": {"replication_factor": "1"},
"durable_writes": true
}'
Update a keyspace.
| Path arguments: |
|
|---|---|
| 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
}'
Drop a keyspace from the cluster.
| Path arguments: |
|
|---|---|
| Responses: | 204 -- Keyspace deleted successfully |
Example
curl -X DELETE http://127.0.0.1:8888/Test_Cluster/keyspaces/test_ks
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
Output:
{
"column_metadata": {
"state": {
"validation_class": "AsciiType",
"index_type": null,
"index_name": null,
"index_options": null
}
},
"column_type": "Standard",
"min_compaction_threshold": 4,
...
}
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: | 201 -- Column family created successfully |
Example
curl -X POST
http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace1/cf/MyColFam
-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,
"bloom_filter_fp_chance": 0.01,
"subcomparator_type": null
}'
Update or modify select attributes of a column family.
| Path arguments: |
|
|---|---|
| Body : | A JSON dictionary describing the attributes of the column family to update. Keys in the dictionary are valid column family attributes, such as read_repair_chance and bloom_filter_fp_chance, in Cassandra. Note that Cassandra does not allow some attributes, such as the column type and the comparator type, to be altered once set. |
Example
curl -X PUT
http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace1/cf/MyColFam
-d '{
"read_repair_chance": 0.1,
"bloom_filter_fp_chance": 0.03,
}'
Set the validation class (data type) for a column.
| Path arguments: |
|
|---|---|
| Body : | A JSON string of the new validation class, such as "UT8Type". |
| Responses: | 200 -- Column validator was set successfully. |
Returns null.
Example
curl -X PUT
http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace1/cf/Users/column/state
-d '"AsciiType"'
Clear the validation class (data type) for a column.
| Path arguments: |
|
|---|---|
| Responses: | 200 -- Column validator was cleared successfully. |
Returns null.
Example
curl -X DELETE
http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace1/cf/Users/column/state
Add a secondary index to a column family.
| Path arguments: |
|
|---|---|
| Body : | A JSON dictionary describing the attributes of the index. Valid keys include validation_class, index_type, index_name, and index_options. |
| Responses: | 201 -- Index was added successfully |
Returns null.
Example
curl -X POST
http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace1/cf/Users/index/state
-d '{
"validation_class": "AsciiType",
"index_type": "KEYS",
"index_name": "state_index",
"index_options": null
}'
Drop a secondary index from a column family.
| Path arguments: |
|
|---|---|
| Responses: | 204 -- Index was dropped successfully |
Returns null.
Example
curl -X DELETE
http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace1/cf/Users/index/state
Truncate a column family. Deletes all data from the column family but does not delete the column family itself.
| Path arguments: |
|
|---|---|
| Responses: | 204 -- Column family truncated successfully |
Returns null.
Example
curl -X DELETE http://127.0.0.1:8888/Test_Cluster/data/test_ks/users
Drop a column family.
| Path arguments: |
|
|---|---|
| Responses: | 204 -- Column family dropped successfully |
Example
curl -X DELETE http://127.0.0.1:8888/Test_Cluster/keyspaces/test_ks/cf/users