Skip to main content

topics

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

Overview

Nametopics
TypeResource
Idgoogle.managedkafka.topics

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringIdentifier. The name of the topic. The topic segment is used when connecting directly to the cluster. Structured like: projects/{project}/locations/{location}/clusters/{cluster}/topics/{topic}
configsobjectOptional. Configurations for the topic that are overridden from the cluster defaults. The key of the map is a Kafka topic property name, for example: cleanup.policy, compression.type.
partitionCountinteger (int32)Required. The number of partitions this topic has. The partition count can only be increased, not decreased. Please note that if partitions are increased for a topic that has a key, the partitioning logic or the ordering of the messages will be affected.
replicationFactorinteger (int32)Required. Immutable. The number of replicas of each partition. A replication factor of 3 is recommended for high availability.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, locationsId, clustersId, topicsIdReturns the properties of a single topic.
listselectprojectsId, locationsId, clustersIdpageSize, pageTokenLists the topics in a given cluster.
createinsertprojectsId, locationsId, clustersIdtopicIdCreates a new topic in a given project and location.
patchupdateprojectsId, locationsId, clustersId, topicsIdupdateMaskUpdates the properties of a single topic.
deletedeleteprojectsId, locationsId, clustersId, topicsIdDeletes a single topic.

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
clustersIdstring
locationsIdstring
projectsIdstring
topicsIdstring
pageSizeinteger (int32)
pageTokenstring
topicIdstring
updateMaskstring (google-fieldmask)

SELECT examples

Returns the properties of a single topic.

SELECT
name,
configs,
partitionCount,
replicationFactor
FROM google.managedkafka.topics
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND clustersId = '{{ clustersId }}' -- required
AND topicsId = '{{ topicsId }}' -- required;

INSERT examples

Creates a new topic in a given project and location.

INSERT INTO google.managedkafka.topics (
data__name,
data__partitionCount,
data__replicationFactor,
data__configs,
projectsId,
locationsId,
clustersId,
topicId
)
SELECT
'{{ name }}',
{{ partitionCount }},
{{ replicationFactor }},
'{{ configs }}',
'{{ projectsId }}',
'{{ locationsId }}',
'{{ clustersId }}',
'{{ topicId }}'
RETURNING
name,
configs,
partitionCount,
replicationFactor
;

UPDATE examples

Updates the properties of a single topic.

UPDATE google.managedkafka.topics
SET
data__name = '{{ name }}',
data__partitionCount = {{ partitionCount }},
data__replicationFactor = {{ replicationFactor }},
data__configs = '{{ configs }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND clustersId = '{{ clustersId }}' --required
AND topicsId = '{{ topicsId }}' --required
AND updateMask = '{{ updateMask}}'
RETURNING
name,
configs,
partitionCount,
replicationFactor;

DELETE examples

Deletes a single topic.

DELETE FROM google.managedkafka.topics
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND clustersId = '{{ clustersId }}' --required
AND topicsId = '{{ topicsId }}' --required;