Skip to main content

kafka_topics

Creates, updates, deletes, gets or lists a kafka_topics resource.

Overview

Namekafka_topics
TypeResource
Iddigitalocean.databases.kafka_topics

Fields

The following fields are returned by SELECT queries:

A JSON object with a key of topic.

NameDatatypeDescription
namestringThe name of the Kafka topic. (example: events)
configobject
partitionsarray
replication_factorintegerThe number of nodes to replicate data across the cluster.
statestringThe state of the Kafka topic. (example: active)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
databases_get_kafka_topicselectdatabase_cluster_uuid, topic_nameTo retrieve a given topic by name from the set of a Kafka cluster's topics,
send a GET request to /v2/databases/$DATABASE_ID/topics/$TOPIC_NAME.

The result will be a JSON object with a topic key.
databases_list_kafka_topicsselectdatabase_cluster_uuidTo list all of a Kafka cluster's topics, send a GET request to
/v2/databases/$DATABASE_ID/topics.

The result will be a JSON object with a topics key.
databases_create_kafka_topicinsertdatabase_cluster_uuid, data__nameTo create a topic attached to a Kafka cluster, send a POST request to
/v2/databases/$DATABASE_ID/topics.

The result will be a JSON object with a topic key.
databases_update_kafka_topicreplacedatabase_cluster_uuid, topic_nameTo update a topic attached to a Kafka cluster, send a PUT request to
/v2/databases/$DATABASE_ID/topics/$TOPIC_NAME.

The result will be a JSON object with a topic key.
databases_delete_kafka_topicdeletedatabase_cluster_uuid, topic_nameTo delete a single topic within a Kafka cluster, send a DELETE request
to /v2/databases/$DATABASE_ID/topics/$TOPIC_NAME.

A status of 204 will be given. This indicates that the request was
processed successfully, but that no response body is needed.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
database_cluster_uuidstring (uuid)A unique identifier for a database cluster. (example: 9cc10173-e9ea-4176-9dbc-a4cee4c4ff30)
topic_namestringThe name used to identify the Kafka topic. (example: customer-events)

SELECT examples

To retrieve a given topic by name from the set of a Kafka cluster's topics,
send a GET request to /v2/databases/$DATABASE_ID/topics/$TOPIC_NAME.

The result will be a JSON object with a topic key.

SELECT
name,
config,
partitions,
replication_factor,
state
FROM digitalocean.databases.kafka_topics
WHERE database_cluster_uuid = '{{ database_cluster_uuid }}' -- required
AND topic_name = '{{ topic_name }}' -- required;

INSERT examples

To create a topic attached to a Kafka cluster, send a POST request to
/v2/databases/$DATABASE_ID/topics.

The result will be a JSON object with a topic key.

INSERT INTO digitalocean.databases.kafka_topics (
data__name,
data__replication_factor,
data__partition_count,
data__config,
database_cluster_uuid
)
SELECT
'{{ name }}' --required,
{{ replication_factor }},
{{ partition_count }},
'{{ config }}',
'{{ database_cluster_uuid }}'
RETURNING
topic
;

REPLACE examples

To update a topic attached to a Kafka cluster, send a PUT request to
/v2/databases/$DATABASE_ID/topics/$TOPIC_NAME.

The result will be a JSON object with a topic key.

REPLACE digitalocean.databases.kafka_topics
SET
data__replication_factor = {{ replication_factor }},
data__partition_count = {{ partition_count }},
data__config = '{{ config }}'
WHERE
database_cluster_uuid = '{{ database_cluster_uuid }}' --required
AND topic_name = '{{ topic_name }}' --required
RETURNING
topic;

DELETE examples

To delete a single topic within a Kafka cluster, send a DELETE request
to /v2/databases/$DATABASE_ID/topics/$TOPIC_NAME.

A status of 204 will be given. This indicates that the request was
processed successfully, but that no response body is needed.

DELETE FROM digitalocean.databases.kafka_topics
WHERE database_cluster_uuid = '{{ database_cluster_uuid }}' --required
AND topic_name = '{{ topic_name }}' --required;