DataStax OpsCenter Documentation

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 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}

HTTP Methods

GET /{cluster_id}/keyspaces

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:
  • ksfields -- Optional. Comma delimited list of explicit keyspace properties to return.
  • cffields -- Optional. 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
  -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"
    },
    ...
  },
  ...
}
GET /{cluster_id}/keyspaces/{ks_name}

Retrieve information about a specific keyspace in the cluster.

Path arguments:
Query params:
  • ksfields -- Optional. Comma delimited list of explicit keyspace properties to return.
  • cffields -- Optional. 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
  -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"
  },
  ...
}
GET /{cluster_id}/keyspaces/{ks_name}/{attribute}

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"
POST /{cluster_id}/keyspaces/{ks_name}

Add a keyspace to the cluster.

Path arguments:
  • cluster_id -- A key, which identifies the node's cluster, in the dictionary returned by GET /cluster-configs.
  • ks_name -- The name of the keyspace to add to the cluster.
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"}
  }'
POST /{cluster_id}/keyspaces/{ks_name}/cf/{cf_name}

Add a column family to a keyspace.

Path arguments:
  • cluster_id -- A key, which identifies the node's cluster, in the dictionary returned by GET /cluster-configs.
  • ks_name -- The name of an existing keyspace.
  • cf_name -- The name of the column family to add.
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 /{cluster_id}/keyspaces/{ks_name}/cf/{cf_name}

Get the description of a column family.

Path arguments:
  • cluster_id -- A key, which identifies the node's cluster, in the dictionary returned by GET /cluster-configs.
  • ks_name -- The name of the keyspace that contains the column family.
  • cf_name -- The name of the column family.

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,
  ...
}
DELETE /{cluster_id}/data/{ks_name}/{cf_name}

Truncate an existing column family. Deletes all data from the column family but does not delete the column family itself.

Path arguments:
  • cluster_id -- A key, which identifies the node's cluster, in the dictionary returned by GET /cluster-configs.
  • ks_name -- The name of the keyspace containing the column family.
  • cf_name -- The name of the column family to truncate.

Returns null.

Example

curl
  http://127.0.0.1:8888/Test_Cluster/data/test_ks/users
  -X DELETE
DELETE /{cluster_id}/keyspaces/{ks_name}/cf/{cf_name}

Delete a column family.

Path arguments:
  • cluster_id -- A key, which identifies the node's cluster, in the dictionary returned by GET /cluster-configs.
  • 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 deleted successfully

Example

curl
  http://127.0.0.1:8888/Test_Cluster/keyspaces/test_ks/cf/users
  -X DELETE
DELETE /{cluster_id}/keyspaces/{ks_name}

Delete an existing keyspace in the cluster.

Path arguments:
  • cluster_id -- A key, which identifies the node's cluster, in the dictionary returned by GET /cluster-configs.
  • ks_name -- The name of the keyspace to delete.
Responses:

204 -- Keyspace deleted successfully

Example

curl
  http://127.0.0.1:8888/Test_Cluster/keyspaces/test_ks
  -X DELETE