Skip to main content

topics

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

Overview

Nametopics
TypeResource
Idconfluent.kafka.topics

Fields

The following fields are returned by SELECT queries:

The topic.

NameDatatypeDescription
cluster_idstring
topic_namestring
authorized_operationsarray
configsobject
is_internalboolean
kindstring
metadataobject
partition_reassignmentsobject
partitionsobject
partitions_countinteger
replication_factorinteger

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_kafka_topicselectcluster_id, topic_name, kafka_endpoint_id, region, cloud_providerinclude_authorized_operationsReturn the topic with the given topic_name.
list_kafka_topicsselectcluster_id, kafka_endpoint_id, region, cloud_providerReturn the list of topics that belong to the specified Kafka cluster.
create_kafka_topicinsertcluster_id, kafka_endpoint_id, region, cloud_provider, topic_nameCreate a topic.
Also supports a dry-run mode that only validates whether the topic creation would succeed
if the validate_only request property is explicitly specified and set to true. Note that
when dry-run mode is being used the response status would be 200 OK instead of 201 Created.
update_partition_count_kafka_topicupdatecluster_id, topic_name, kafka_endpoint_id, region, cloud_provider, partitions_countIncrease the number of partitions for a topic. To update other topic
configurations, see https://docs.confluent.io/cloud/current/api.html#tag/Configs-(v3)/operation/updateKafkaTopicConfig.
delete_kafka_topicdeletecluster_id, topic_name, kafka_endpoint_id, region, cloud_providerDelete the topic with the given topic_name.

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
cloud_providerstringCloud provider, lowercase: aws, gcp, or azure (from the cluster spec.cloud). (default: cloud)
cluster_idstringThe Kafka cluster ID. (example: cluster-1)
kafka_endpoint_idstringPer-cluster Kafka REST endpoint ID (the pkc-* host prefix from the Confluent UI Cluster -> Overview -> REST endpoint, or extract from confluent.managed_kafka_clusters.clusters spec.http_endpoint). (default: pkc-00000)
regionstringCloud region the cluster runs in, e.g. ap-southeast-2 (from the cluster spec.region). (default: region)
topic_namestringThe topic name. (example: topic-1)
include_authorized_operationsbooleanSpecify if authorized operations should be included in the response.

SELECT examples

Return the topic with the given topic_name.

SELECT
cluster_id,
topic_name,
authorized_operations,
configs,
is_internal,
kind,
metadata,
partition_reassignments,
partitions,
partitions_count,
replication_factor
FROM confluent.kafka.topics
WHERE cluster_id = '{{ cluster_id }}' -- required
AND topic_name = '{{ topic_name }}' -- required
AND kafka_endpoint_id = '{{ kafka_endpoint_id }}' -- required
AND region = '{{ region }}' -- required
AND cloud_provider = '{{ cloud_provider }}' -- required
AND include_authorized_operations = '{{ include_authorized_operations }}'
;

INSERT examples

Create a topic.
Also supports a dry-run mode that only validates whether the topic creation would succeed
if the validate_only request property is explicitly specified and set to true. Note that
when dry-run mode is being used the response status would be 200 OK instead of 201 Created.

INSERT INTO confluent.kafka.topics (
topic_name,
partitions_count,
replication_factor,
configs,
validate_only,
cluster_id,
kafka_endpoint_id,
region,
cloud_provider
)
SELECT
'{{ topic_name }}' /* required */,
{{ partitions_count }},
{{ replication_factor }},
'{{ configs }}',
{{ validate_only }},
'{{ cluster_id }}',
'{{ kafka_endpoint_id }}',
'{{ region }}',
'{{ cloud_provider }}'
RETURNING
cluster_id,
topic_name,
authorized_operations,
configs,
is_internal,
kind,
metadata,
partition_reassignments,
partitions,
partitions_count,
replication_factor
;

UPDATE examples

Increase the number of partitions for a topic. To update other topic
configurations, see https://docs.confluent.io/cloud/current/api.html#tag/Configs-(v3)/operation/updateKafkaTopicConfig.

UPDATE confluent.kafka.topics
SET
partitions_count = {{ partitions_count }}
WHERE
cluster_id = '{{ cluster_id }}' --required
AND topic_name = '{{ topic_name }}' --required
AND kafka_endpoint_id = '{{ kafka_endpoint_id }}' --required
AND region = '{{ region }}' --required
AND cloud_provider = '{{ cloud_provider }}' --required
AND partitions_count = '{{ partitions_count }}' --required
RETURNING
cluster_id,
topic_name,
authorized_operations,
configs,
is_internal,
kind,
metadata,
partition_reassignments,
partitions,
partitions_count,
replication_factor;

DELETE examples

Delete the topic with the given topic_name.

DELETE FROM confluent.kafka.topics
WHERE cluster_id = '{{ cluster_id }}' --required
AND topic_name = '{{ topic_name }}' --required
AND kafka_endpoint_id = '{{ kafka_endpoint_id }}' --required
AND region = '{{ region }}' --required
AND cloud_provider = '{{ cloud_provider }}' --required
;