topics
Creates, updates, deletes, gets or lists a topics resource.
Overview
| Name | topics |
| Type | Resource |
| Id | confluent.kafka.topics |
Fields
The following fields are returned by SELECT queries:
- get_kafka_topic
- list_kafka_topics
The topic.
| Name | Datatype | Description |
|---|---|---|
cluster_id | string | |
topic_name | string | |
authorized_operations | array | |
configs | object | |
is_internal | boolean | |
kind | string | |
metadata | object | |
partition_reassignments | object | |
partitions | object | |
partitions_count | integer | |
replication_factor | integer |
The list of topics.
| Name | Datatype | Description |
|---|---|---|
cluster_id | string | |
topic_name | string | |
authorized_operations | array | |
configs | object | |
is_internal | boolean | |
kind | string | |
metadata | object | |
partition_reassignments | object | |
partitions | object | |
partitions_count | integer | |
replication_factor | integer |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_kafka_topic | select | cluster_id, topic_name, kafka_endpoint_id, region, cloud_provider | include_authorized_operations | Return the topic with the given topic_name. |
list_kafka_topics | select | cluster_id, kafka_endpoint_id, region, cloud_provider | Return the list of topics that belong to the specified Kafka cluster. | |
create_kafka_topic | insert | cluster_id, kafka_endpoint_id, region, cloud_provider, topic_name | 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 thatwhen dry-run mode is being used the response status would be 200 OK instead of 201 Created. | |
update_partition_count_kafka_topic | update | cluster_id, topic_name, kafka_endpoint_id, region, cloud_provider, partitions_count | 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. | |
delete_kafka_topic | delete | cluster_id, topic_name, kafka_endpoint_id, region, cloud_provider | Delete 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.
| Name | Datatype | Description |
|---|---|---|
cloud_provider | string | Cloud provider, lowercase: aws, gcp, or azure (from the cluster spec.cloud). (default: cloud) |
cluster_id | string | The Kafka cluster ID. (example: cluster-1) |
kafka_endpoint_id | string | Per-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) |
region | string | Cloud region the cluster runs in, e.g. ap-southeast-2 (from the cluster spec.region). (default: region) |
topic_name | string | The topic name. (example: topic-1) |
include_authorized_operations | boolean | Specify if authorized operations should be included in the response. |
SELECT examples
- get_kafka_topic
- list_kafka_topics
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 }}'
;
Return the list of topics that belong to the specified Kafka cluster.
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 kafka_endpoint_id = '{{ kafka_endpoint_id }}' -- required
AND region = '{{ region }}' -- required
AND cloud_provider = '{{ cloud_provider }}' -- required
;
INSERT examples
- create_kafka_topic
- Manifest
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
;
# Description fields are for documentation purposes
- name: topics
props:
- name: cluster_id
value: "{{ cluster_id }}"
description: Required parameter for the topics resource.
- name: kafka_endpoint_id
value: "{{ kafka_endpoint_id }}"
description: Required parameter for the topics resource.
- name: region
value: "{{ region }}"
description: Required parameter for the topics resource.
- name: cloud_provider
value: "{{ cloud_provider }}"
description: Required parameter for the topics resource.
- name: topic_name
value: "{{ topic_name }}"
- name: partitions_count
value: {{ partitions_count }}
- name: replication_factor
value: {{ replication_factor }}
- name: configs
value:
- name: "{{ name }}"
value: "{{ value }}"
- name: validate_only
value: {{ validate_only }}
UPDATE examples
- update_partition_count_kafka_topic
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_kafka_topic
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
;