Reference documentation and code samples for the Google Cloud Managed Kafka V1 Client class Topic.
A Kafka topic in a given cluster.
Generated from protobuf messagegoogle.cloud.managedkafka.v1.Topic
Namespace
Google \ Cloud \ ManagedKafka \ V1
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ name
string
Identifier. The name of the topic. Thetopicsegment is used when connecting directly to the cluster. Structured like: projects/{project}/locations/{location}/clusters/{cluster}/topics/{topic}
↳ partition_count
int
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.
↳ replication_factor
int
Required. Immutable. The number of replicas of each partition. A replication factor of 3 is recommended for high availability.
Optional. 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.
getName
Identifier. The name of the topic. Thetopicsegment is used when
connecting directly to the cluster. Structured like:
projects/{project}/locations/{location}/clusters/{cluster}/topics/{topic}
Returns
Type
Description
string
setName
Identifier. The name of the topic. Thetopicsegment is used when
connecting directly to the cluster. Structured like:
projects/{project}/locations/{location}/clusters/{cluster}/topics/{topic}
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getPartitionCount
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.
Returns
Type
Description
int
setPartitionCount
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.
Parameter
Name
Description
var
int
Returns
Type
Description
$this
getReplicationFactor
Required. Immutable. The number of replicas of each partition. A
replication factor of 3 is recommended for high availability.
Returns
Type
Description
int
setReplicationFactor
Required. Immutable. The number of replicas of each partition. A
replication factor of 3 is recommended for high availability.
Parameter
Name
Description
var
int
Returns
Type
Description
$this
getConfigs
Optional. 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.
Optional. 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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Google Cloud Managed Kafka V1 Client - Class Topic (0.6.1)\n\nVersion latestkeyboard_arrow_down\n\n- [0.6.1 (latest)](/php/docs/reference/cloud-managedkafka/latest/V1.Topic)\n- [0.6.0](/php/docs/reference/cloud-managedkafka/0.6.0/V1.Topic)\n- [0.5.0](/php/docs/reference/cloud-managedkafka/0.5.0/V1.Topic)\n- [0.4.1](/php/docs/reference/cloud-managedkafka/0.4.1/V1.Topic)\n- [0.3.1](/php/docs/reference/cloud-managedkafka/0.3.1/V1.Topic)\n- [0.2.3](/php/docs/reference/cloud-managedkafka/0.2.3/V1.Topic)\n- [0.1.3](/php/docs/reference/cloud-managedkafka/0.1.3/V1.Topic) \nReference documentation and code samples for the Google Cloud Managed Kafka V1 Client class Topic.\n\nA Kafka topic in a given cluster.\n\nGenerated from protobuf message `google.cloud.managedkafka.v1.Topic`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ ManagedKafka \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getName\n\nIdentifier. The name of the topic. The `topic` segment is used when\nconnecting directly to the cluster. Structured like:\nprojects/{project}/locations/{location}/clusters/{cluster}/topics/{topic}\n\n### setName\n\nIdentifier. The name of the topic. The `topic` segment is used when\nconnecting directly to the cluster. Structured like:\nprojects/{project}/locations/{location}/clusters/{cluster}/topics/{topic}\n\n### getPartitionCount\n\nRequired. The number of partitions this topic has. The partition count can\nonly be increased, not decreased. Please note that if partitions are\nincreased for a topic that has a key, the partitioning logic or the\nordering of the messages will be affected.\n\n### setPartitionCount\n\nRequired. The number of partitions this topic has. The partition count can\nonly be increased, not decreased. Please note that if partitions are\nincreased for a topic that has a key, the partitioning logic or the\nordering of the messages will be affected.\n\n### getReplicationFactor\n\nRequired. Immutable. The number of replicas of each partition. A\nreplication factor of 3 is recommended for high availability.\n\n### setReplicationFactor\n\nRequired. Immutable. The number of replicas of each partition. A\nreplication factor of 3 is recommended for high availability.\n\n### getConfigs\n\nOptional. Configurations for the topic that are overridden from the cluster\ndefaults. The key of the map is a Kafka topic property name, for example:\n`cleanup.policy`, `compression.type`.\n\n### setConfigs\n\nOptional. Configurations for the topic that are overridden from the cluster\ndefaults. The key of the map is a Kafka topic property name, for example:\n`cleanup.policy`, `compression.type`."]]