kafka_topics
Creates, updates, deletes, gets or lists a kafka_topics
resource.
Overview
Name | kafka_topics |
Type | Resource |
Id | digitalocean.databases.kafka_topics |
Fields
The following fields are returned by SELECT
queries:
- databases_get_kafka_topic
- databases_list_kafka_topics
A JSON object with a key of topic
.
Name | Datatype | Description |
---|---|---|
name | string | The name of the Kafka topic. (example: events) |
config | object | |
partitions | array | |
replication_factor | integer | The number of nodes to replicate data across the cluster. |
state | string | The state of the Kafka topic. (example: active) |
A JSON object with a key of topics
.
Name | Datatype | Description |
---|---|---|
name | string | The name of the Kafka topic. (example: events) |
partition_count | integer | The number of partitions available for the topic. On update, this value can only be increased. |
replication_factor | integer | The number of nodes to replicate data across the cluster. |
state | string | The state of the Kafka topic. (example: active) |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
databases_get_kafka_topic | select | database_cluster_uuid , topic_name | 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. | |
databases_list_kafka_topics | select | database_cluster_uuid | To 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_topic | insert | database_cluster_uuid , data__name | 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. | |
databases_update_kafka_topic | replace | database_cluster_uuid , topic_name | 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. | |
databases_delete_kafka_topic | delete | database_cluster_uuid , topic_name | 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. |
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.
Name | Datatype | Description |
---|---|---|
database_cluster_uuid | string (uuid) | A unique identifier for a database cluster. (example: 9cc10173-e9ea-4176-9dbc-a4cee4c4ff30) |
topic_name | string | The name used to identify the Kafka topic. (example: customer-events) |
SELECT
examples
- databases_get_kafka_topic
- databases_list_kafka_topics
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;
To 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.
SELECT
name,
partition_count,
replication_factor,
state
FROM digitalocean.databases.kafka_topics
WHERE database_cluster_uuid = '{{ database_cluster_uuid }}' -- required;
INSERT
examples
- databases_create_kafka_topic
- Manifest
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
;
# Description fields are for documentation purposes
- name: kafka_topics
props:
- name: database_cluster_uuid
value: string (uuid)
description: Required parameter for the kafka_topics resource.
- name: name
value: string
description: >
The name of the Kafka topic.
- name: replication_factor
value: integer
description: >
The number of nodes to replicate data across the cluster.
- name: partition_count
value: integer
description: >
The number of partitions available for the topic. On update, this value can only be increased.
- name: config
value: object
REPLACE
examples
- databases_update_kafka_topic
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
- databases_delete_kafka_topic
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;